gnome-build patch
- From: Jeroen Zwartepoorte <jeroen xs4all nl>
- To: jpr ximian com
- Cc: Gnome Devtools list <gnome-devtools gnome org>
- Subject: gnome-build patch
- Date: 23 Aug 2002 15:05:04 +0200
Hi JP,
So after gustavo fixed a crasher bug yesterday, i finished some other
outstanding gnome-build things today.
gnome-build's status now is that it's pretty stable and has the same
functionality as the current bonobo-based cvs. There's still an issue
where having the symbol-browser loaded at the same time causes some
weird things, but i'm inclined to blame that on the symbol-browser, not
gnome-build (runs perfectly without the symbol-browser). The 100% CPU
issue happened again for me today, _with_ the symbol-browser loaded (i
only loaded the symbol-browser today again to see how it would
interact).
Anyway, i'd like to commit my changes now to gnome-build and anjuta2 and
then continue hacking from there on (and other people can test the new
framework).
I'm going to delay committing the terminal plugin changes for now until
the vte widget has stabilized. There's too much development going on
there to have a stable terminal plugin.
OK to commit?
Jeroen
p.s. This mail is probably going to be > 100KB again, so could you OK it
in the moderation queue?
? .tm_project.cache
? autom4te-2.53.cache
? gbf.patch
? src/lib_new
? src/backends/libgbf_am/gbf-am-parse
? src/backends/libgbf_am/gbf-am.server.in
? src/backends/libgbf_am/GBF/Makefile
? src/backends/libgbf_am/GBF/Makefile.in
? src/lib/gbf-backend.c
? src/lib/gbf-backend.h
? src/lib/gbf-project.c
? src/lib/gbf-project.h
? src/lib/glue-factory.c
? src/lib/glue-factory.h
? src/lib/glue-plugin.c
? src/lib/glue-plugin.h
? src/lib/test.c
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-build/ChangeLog,v
retrieving revision 1.101
diff -u -r1.101 ChangeLog
--- ChangeLog 1 Aug 2002 23:03:08 -0000 1.101
+++ ChangeLog 23 Aug 2002 12:59:45 -0000
@@ -1,3 +1,47 @@
+2002-08-23 Jeroen Zwartepoorte <jeroen xs4all nl>
+
+ * configure.in:
+ * gnome-build-1.0.pc.in:
+ * src/backends/libgbf_am/Makefile.am:
+ * src/backends/libgbf_am/gbf-am-project.c: (read_output),
+ (spawn_script), (parse_error_buffer), (build_project_op),
+ (impl_load), (impl_build), (impl_get_group),
+ (impl_configure_new_group), (impl_configure_group),
+ (impl_add_group), (impl_remove_group), (impl_get_target),
+ (foreach_target), (impl_get_all_targets),
+ (impl_configure_new_target), (impl_configure_target),
+ (impl_add_target), (impl_remove_target), (impl_name_for_type),
+ (impl_icon_for_type), (impl_get_source), (foreach_source),
+ (impl_get_all_sources), (impl_configure_new_source),
+ (impl_configure_source), (impl_add_source), (impl_remove_source),
+ (gbf_am_project_dispose), (gbf_am_project_get_property),
+ (gbf_am_project_class_init), (gbf_am_project_instance_init),
+ (gbf_am_project_new):
+ * src/backends/libgbf_am/gbf-am-project.h:
+ * src/backends/libgbf_am/test.c: (main):
+ * src/controls/Makefile.am:
+ * src/controls/gbf-build-info.c: (gbf_build_info_class_init),
+ (gbf_build_info_instance_init), (get_property), (set_property),
+ (dispose), (file_msg), (link_clicked_cb):
+ * src/controls/gbf-build-info.h:
+ * src/controls/gbf-project-tree.c: (gbf_project_tree_class_init),
+ (gbf_project_tree_instance_init), (get_property), (set_property),
+ (dispose), (set_pixbuf), (set_text), (load_data),
+ (row_activated_cb), (insert_no_project_node):
+ * src/controls/gbf-project-tree.h:
+ * src/controls/gbf-target-tree.c: (gbf_target_tree_class_init),
+ (gbf_target_tree_instance_init), (get_property), (set_property),
+ (dispose), (set_pixbuf), (set_text), (load_data),
+ (row_activated_cb):
+ * src/controls/gbf-target-tree.h:
+ * src/controls/test-controls.c: (open_cb), (open_project),
+ (create_window), (main):
+ * src/lib/Makefile.am:
+
+ Remove bonobo usage for backend activation and communication with the
+ backend. Instead, use glue (gmodule based) to create project backend.
+ Lots of CORBA code removed & result should be easier to work with.
+
2002-08-01 Christophe Merlet <christophe merlet net>
* configure.in: Added fr to ALL_LINGUAS
Index: configure.in
===================================================================
RCS file: /cvs/gnome/gnome-build/configure.in,v
retrieving revision 1.26
diff -u -r1.26 configure.in
--- configure.in 1 Aug 2002 23:03:08 -0000 1.26
+++ configure.in 23 Aug 2002 12:59:46 -0000
@@ -132,6 +132,17 @@
AC_DEFINE_UNQUOTED(SCRIPTS_DIR, "${prefix}/bin")
fi
+dnl Set PREFIX
+if test "x${prefix}" = "xNONE"; then
+ packageprefix=${ac_default_prefix}
+else
+ packageprefix=${prefix}
+fi
+
+# Set the path to the backends directory so we don't litter $(prefix)/lib :-)
+gbf_backends_dir="${packageprefix}/lib/gnome-build/backends"
+AC_SUBST(gbf_backends_dir)
+
AC_OUTPUT([
Makefile
src/Makefile
Index: gnome-build-1.0.pc.in
===================================================================
RCS file: /cvs/gnome/gnome-build/gnome-build-1.0.pc.in,v
retrieving revision 1.3
diff -u -r1.3 gnome-build-1.0.pc.in
--- gnome-build-1.0.pc.in 14 Mar 2002 07:45:31 -0000 1.3
+++ gnome-build-1.0.pc.in 23 Aug 2002 12:59:46 -0000
@@ -7,6 +7,6 @@
Name: gnome-build
Description: Gnome Build Framework
Version: @VERSION@
-Requires: libbonoboui-2.0 libgnome-2.0 gtk+-2.0 libgtkhtml-2.0 libxml-2.0
-Libs: -L${libdir} -lgbf-1
+Requires: libgnome-2.0 gtk+-2.0 libgtkhtml-2.0 libxml-2.0
+Libs: -L${libdir} -lgbf-1 -lgbf-widgets-1
Cflags: -I${includedir}
Index: src/backends/libgbf_am/Makefile.am
===================================================================
RCS file: /cvs/gnome/gnome-build/src/backends/libgbf_am/Makefile.am,v
retrieving revision 1.13
diff -u -r1.13 Makefile.am
--- src/backends/libgbf_am/Makefile.am 12 Jul 2002 04:38:45 -0000 1.13
+++ src/backends/libgbf_am/Makefile.am 23 Aug 2002 12:59:46 -0000
@@ -4,38 +4,40 @@
-DGNOMELOCALEDIR=\""$(datadir)/locale"\"\
-DG_DISABLE_DEPRECATED \
-DGTK_DISABLE_DEPRECATED \
- -I$(top_srcdir)/src/controls \
$(WARN_CFLAGS) \
$(GBF_AM_BACKEND_CFLAGS) \
-I$(top_builddir)/src/lib
-bin_PROGRAMS = gbf-am-project
-noinst_PROGRAMS = test
bin_SCRIPTS = gbf-am-parse gbf-am-build
-gbf_am_project_SOURCES = \
- gbf-am-project.c \
- gbf-am-project.h \
- gbf-am-config.c \
- gbf-am-config.h \
- main.c
+gbf_backenddir = $(gbf_backends_dir)
+
+gbf_backend_LTLIBRARIES = \
+ libgbf-am.la
+
+libgbf_am_la_SOURCES = \
+ gbf-am-project.c \
+ gbf-am-project.h \
+ gbf-am-config.c \
+ gbf-am-config.h
-gbf_am_project_LDADD = \
- $(top_builddir)/src/lib/libgbf-1.la \
+libgbf_am_la_LIBADD = \
+ $(top_builddir)/src/lib/libgbf-1.la \
$(GBF_AM_BACKEND_LIBS)
-test_SOURCES = \
+noinst_PROGRAMS = test
+
+test_SOURCES = \
test.c
-test_LDADD = \
- $(top_builddir)/src/lib/libgbf-1.la \
+test_LDADD = \
+ $(top_builddir)/src/lib/libgbf-1.la \
$(GBF_AM_BACKEND_LIBS)
-serverdir = $(libdir)/bonobo/servers
-server_in_files = GNOME_Development_Project_Automake.server.in
-server_DATA = $(server_in_files:.server.in=.server)
+server_in_files = gbf-am.server.in
+gbf_backend_DATA = $(server_in_files:.server.in=.server)
@INTLTOOL_SERVER_RULE@
-EXTRA_DIST = \
- $(server_DATA)
+EXTRA_DIST = \
+ $(gbf_backend_DATA)
Index: src/backends/libgbf_am/gbf-am-project.c
===================================================================
RCS file: /cvs/gnome/gnome-build/src/backends/libgbf_am/gbf-am-project.c,v
retrieving revision 1.25
diff -u -r1.25 gbf-am-project.c
--- src/backends/libgbf_am/gbf-am-project.c 12 Jul 2002 04:38:46 -0000 1.25
+++ src/backends/libgbf_am/gbf-am-project.c 23 Aug 2002 12:59:48 -0000
@@ -32,19 +32,20 @@
#include <bonobo/bonobo-property-bag.h>
#include <bonobo/bonobo-event-source.h>
#include <fcntl.h>
+#include <libgnome/gnome-macros.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
+#include "gbf-am-project.h"
+#include "gbf-am-config.h"
+#include "gbf-project.h"
+#include "glue-plugin.h"
+
#include "program.xpm"
#include "shared.xpm"
#include "static.xpm"
#include "unknown.xpm"
-#include "gnome-build.h"
-#include "gbf-am-project.h"
-#include "gbf-am-config.h"
-
-
-#define EMPTY_STRING ""
+#define UNIMPLEMENTED /* g_warning (G_STRLOC": unimplemented") */
typedef enum {
BUILD
@@ -55,7 +56,7 @@
GbfAmProject *prj;
GbfAmProjectOpType type;
- GNOME_Development_BuildType build_type;
+ GbfBuildType build_type;
} GbfAmProjectOp;
/* structures for holding project data */
@@ -158,7 +159,8 @@
BonoboEventSource *event_source;
};
-enum Properties {
+enum {
+ PROP_0,
PROP_PROJECT_DIR
};
@@ -201,19 +203,11 @@
* Private prototypes -------------------------------------
*/
-#define PARENT_TYPE BONOBO_OBJECT_TYPE
-static BonoboObjectClass *parent_class = NULL;
-
-static void gbf_am_project_get_prop (BonoboPropertyBag *bag, BonoboArg *arg,
- guint arg_id, CORBA_Environment *ev,
- gpointer user_data);
-static void gbf_am_project_set_prop (BonoboPropertyBag *bag, const BonoboArg *arg,
- guint arg_id, CORBA_Environment *ev,
- gpointer user_data);
-
static void build_project_op (GbfAmProject *prj,
- GNOME_Development_BuildType type);
+ GbfBuildType type);
+static GbfProject *parent_class;
+/*GNOME_CLASS_BOILERPLATE (GbfAmProject, gbf_am_project, GbfProject, GBF_TYPE_PROJECT);*/
/*
* Queue operations ------------------------
@@ -1081,8 +1075,8 @@
if (!retval) {
/* eof was reached or some error ocurred */
- g_io_channel_shutdown (data->error.channel, FALSE, NULL);
- g_io_channel_unref (data->error.channel);
+ g_io_channel_shutdown (data->output.channel, FALSE, NULL);
+ g_io_channel_unref (data->output.channel);
data->output.channel = NULL;
/* returning false will remove the source */
data->output_source = 0;
@@ -1193,11 +1187,7 @@
/* set timeout */
data->ticks = 0;
data->max_ticks = timeout * 1000 / CHECK_TIMEOUT;
-
- /* crap!
- FIXME: putenv() is not portable */
- putenv ("_MEMPROF_SOCKET=");
-
+
g_message ("Spawning script");
if (!g_spawn_async_with_pipes (NULL, argv, NULL,
@@ -1373,6 +1363,7 @@
bonobo_event_source_notify_listeners (priv->event_source, "build-file", arg, NULL);
bonobo_arg_release (arg);
} else if (!strncmp (line, "ERROR: ", 6)) {
+#if 0
GNOME_Development_BuildError build_err;
int i, max = 3;
g_print ("Line: %s\n", line);
@@ -1405,6 +1396,7 @@
"build-error",
arg, NULL);
bonobo_arg_release (arg);
+#endif
}
if (tokens != NULL)
g_strfreev (tokens);
@@ -1498,22 +1490,24 @@
}
static void
-build_project_op (GbfAmProject *prj,
- GNOME_Development_BuildType type)
+build_project_op (GbfAmProject *prj,
+ GbfBuildType type)
{
BonoboArg *arg;
char *argv[] = { BUILD_SCRIPT_NAME, "--build", "", prj->priv->project_dir, 0 };
switch (type) {
- case GNOME_Development_ALL:
+ case GBF_BUILD_ALL:
argv[2] = "all";
break;
- case GNOME_Development_CURRENT:
+ case GBF_BUILD_CURRENT:
argv[2] = "all";
break;
- case GNOME_Development_INSTALL:
+ case GBF_BUILD_INSTALL:
argv[2] = "install";
break;
+ default:
+ break;
}
if (launch_build_script (argv, prj) != 0) {
@@ -1641,371 +1635,264 @@
}
/*
- * IDL methods ------------------------------------------
+ * GbfProjectIface methods ------------------------------------------
*/
static void
-impl_load (PortableServer_Servant servant,
- const CORBA_char *path,
- CORBA_Environment *ev)
+impl_load (GbfProject *project,
+ const char *path,
+ GError **error)
{
- GbfAmProject *prj;
- GbfAmProjectPrivate *priv;
-
- prj = GBF_AM_PROJECT (bonobo_object_from_servant (servant));
- bonobo_return_if_fail (prj != NULL, ev);
- priv = prj->priv;
-
- if (priv->project_dir) {
+ GbfAmProject *prj = GBF_AM_PROJECT (project);
+
+ if (prj->priv->project_dir) {
/* FIXME: do we really want to allow object reutilization */
project_unload (prj);
project_init (prj);
}
-
- if (!g_file_test (path, G_FILE_TEST_IS_DIR)) {
- bonobo_exception_set (ev, ex_GNOME_Development_Project_DoesntExist);
+
+ if (!g_file_test (path, G_FILE_TEST_IS_DIR)) {
+ if (error) {
+ *error = g_error_new (GBF_PROJECT_ERROR,
+ GBF_PROJECT_ERROR_DOESNT_EXIST,
+ _("Project doesn't exist"));
+ }
return;
}
-
- if (get_project (prj, (char *)path) < 0)
- bonobo_exception_set (ev, ex_GNOME_Development_Project_Malformed);
+
+ if (get_project (prj, (char *)path) < 0) {
+ if (error) {
+ *error = g_error_new (GBF_PROJECT_ERROR,
+ GBF_PROJECT_ERROR_PROJECT_MALFORMED,
+ _("Malformed project"));
+ }
+ }
}
static void
-impl_build (PortableServer_Servant servant,
- GNOME_Development_BuildType type,
- CORBA_Environment *ev)
+impl_build (GbfProject *project,
+ GbfBuildType type,
+ GError **error)
{
- GbfAmProject *prj;
+ GbfAmProject *prj = GBF_AM_PROJECT (project);
GbfAmProjectOp *op;
-
- prj = GBF_AM_PROJECT (bonobo_object_from_servant (servant));
- bonobo_return_if_fail (prj != NULL, ev);
op = g_new0 (GbfAmProjectOp, 1);
op->prj = prj;
op->type = BUILD;
op->build_type = type;
-
+
queue_op (prj, op);
}
-static GNOME_Development_Group *
-impl_get_group (PortableServer_Servant servant,
- const CORBA_char *id,
- CORBA_Environment *ev)
+static GbfProjectGroup *
+impl_get_group (GbfProject *project,
+ const char *id,
+ GError **error)
{
- GbfAmProject *prj;
- GbfAmProjectPrivate *priv;
- GNOME_Development_Group *corba_group;
+ GbfAmProject *prj = GBF_AM_PROJECT (project);
GbfAmGroup *group;
- GList *lp;
- gint i;
-
- prj = GBF_AM_PROJECT (bonobo_object_from_servant (servant));
- bonobo_return_val_if_fail (prj != NULL, NULL, ev);
- priv = prj->priv;
+ GbfProjectGroup *grp;
+ GList *l;
- group = g_hash_table_lookup (priv->groups, id);
+ group = g_hash_table_lookup (prj->priv->groups, id);
if (group == NULL) {
- bonobo_exception_set (ev, ex_GNOME_Development_Project_DoesntExist);
- return CORBA_OBJECT_NIL;
+ if (error) {
+ *error = g_error_new (GBF_PROJECT_ERROR,
+ GBF_PROJECT_ERROR_DOESNT_EXIST,
+ _("Group doesn't exist"));
+ }
+ return NULL;
}
- /* create CORBA group structure */
- corba_group = GNOME_Development_Group__alloc ();
-
- corba_group->id = CORBA_string_dup (group->id);
+ grp = g_new0 (GbfProjectGroup, 1);
+ grp->id = g_strdup (group->id);
+ grp->name = g_strdup (group->name);
+
if (group->parent)
- corba_group->parent_id = CORBA_string_dup (group->parent->id);
+ grp->parent_id = g_strdup (group->parent->id);
else
- corba_group->parent_id = CORBA_string_dup (EMPTY_STRING);
-
- corba_group->name = CORBA_string_dup (group->name);
+ grp->parent_id = NULL;
- /* build children groups list */
- corba_group->groups._maximum = corba_group->groups._length =
- g_list_length (group->groups);
- corba_group->groups._buffer = GNOME_Development_TargetList_allocbuf (
- corba_group->groups._maximum);
- corba_group->groups._release = CORBA_TRUE;
-
- for (lp = group->groups, i = 0; lp; lp = lp->next, i++)
- corba_group->groups._buffer [i] =
- CORBA_string_dup (((GbfAmGroup *) lp->data)->id);
-
- /* build targets list */
- corba_group->targets._maximum = corba_group->targets._length =
- g_list_length (group->targets);
- corba_group->targets._buffer = GNOME_Development_TargetList_allocbuf (
- corba_group->targets._maximum);
- corba_group->targets._release = CORBA_TRUE;
-
- for (lp = group->targets, i = 0; lp; lp = lp->next, i++)
- corba_group->targets._buffer [i] =
- CORBA_string_dup (((GbfAmTarget *) lp->data)->id);
-
- return corba_group;
-}
-
-static Bonobo_Control
-impl_configure_new_group (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- GbfAmProject *prj;
- GbfAmProjectPrivate *priv;
-
- prj = GBF_AM_PROJECT (bonobo_object_from_servant (servant));
- bonobo_return_val_if_fail (prj != NULL, NULL, ev);
- priv = prj->priv;
+ grp->groups = NULL;
+ for (l = group->groups; l; l = l->next) {
+ GbfAmGroup *group2 = l->data;
+ grp->groups = g_list_append (grp->groups, g_strdup (group2->id));
+ }
- return CORBA_OBJECT_NIL;
+ grp->targets = NULL;
+ for (l = group->targets; l; l = l->next) {
+ GbfAmTarget *target = l->data;
+ grp->targets = g_list_append (grp->targets, g_strdup (target->id));
+ }
+
+ return grp;
}
-static Bonobo_Control
-impl_configure_group (PortableServer_Servant servant,
- const CORBA_char *id,
- CORBA_Environment *ev)
+static GtkWidget *
+impl_configure_new_group (GbfProject *project,
+ GError **error)
{
- GbfAmProject *prj = GBF_AM_PROJECT (bonobo_object_from_servant (servant));
+ UNIMPLEMENTED;
- prj = NULL;
+ return NULL;
+}
+
+static GtkWidget *
+impl_configure_group (GbfProject *project,
+ const char *id,
+ GError **error)
+{
+ UNIMPLEMENTED;
- return CORBA_OBJECT_NIL;
+ return NULL;
}
-static CORBA_char *
-impl_add_group (PortableServer_Servant servant,
- const CORBA_char *parent_id,
- const CORBA_char *name,
- CORBA_Environment *ev)
+static const char *
+impl_add_group (GbfProject *project,
+ const char *parent_id,
+ const char *id,
+ GError **error)
{
- GbfAmProject *prj;
- GbfAmProjectPrivate *priv;
-
- prj = GBF_AM_PROJECT (bonobo_object_from_servant (servant));
- bonobo_return_val_if_fail (prj != NULL, NULL, ev);
- priv = prj->priv;
+ UNIMPLEMENTED;
return NULL;
}
static void
-impl_remove_group (PortableServer_Servant servant,
- const CORBA_char *id,
- CORBA_Environment *ev)
+impl_remove_group (GbfProject *project,
+ const char *id,
+ GError **error)
{
- GbfAmProject *prj;
- GbfAmProjectPrivate *priv;
-
- prj = GBF_AM_PROJECT (bonobo_object_from_servant (servant));
- bonobo_return_if_fail (prj != NULL, ev);
- priv = prj->priv;
+ UNIMPLEMENTED;
}
-static GNOME_Development_Target *
-impl_get_target (PortableServer_Servant servant,
- const CORBA_char *id,
- CORBA_Environment *ev)
+static GbfProjectTarget *
+impl_get_target (GbfProject *project,
+ const char *id,
+ GError **error)
{
- GbfAmProject *prj;
- GbfAmProjectPrivate *priv;
- GNOME_Development_Target *corba_target;
+ GbfAmProject *prj = GBF_AM_PROJECT (project);
GbfAmTarget *target;
- GList *lp;
- gint i;
-
- prj = GBF_AM_PROJECT (bonobo_object_from_servant (servant));
- bonobo_return_val_if_fail (prj != NULL, NULL, ev);
- priv = prj->priv;
+ GbfProjectTarget *trgt;
+ GList *l;
- target = g_hash_table_lookup (priv->targets, id);
+ target = g_hash_table_lookup (prj->priv->targets, id);
if (target == NULL) {
- bonobo_exception_set (ev, ex_GNOME_Development_Project_DoesntExist);
- return CORBA_OBJECT_NIL;
+ if (error) {
+ *error = g_error_new (GBF_PROJECT_ERROR,
+ GBF_PROJECT_ERROR_DOESNT_EXIST,
+ _("Target doesn't exist"));
+ }
+ return NULL;
}
-
- corba_target = GNOME_Development_Target__alloc ();
-
- corba_target->id = CORBA_string_dup (target->id);
+
+ trgt = g_new0 (GbfProjectTarget, 1);
+ trgt->id = g_strdup (target->id);
+ trgt->name = g_strdup (target->name);
+ trgt->type = g_strdup (target->type);
+
if (target->group)
- corba_target->group_id = CORBA_string_dup (target->group->id);
+ trgt->group_id = g_strdup (target->group->id);
else
- corba_target->group_id = CORBA_string_dup (EMPTY_STRING);
-
- corba_target->name = CORBA_string_dup (target->name);
- corba_target->type = CORBA_string_dup (target->type);
- corba_target->sources._maximum = corba_target->sources._length =
- g_list_length (target->sources);
- corba_target->sources._buffer = GNOME_Development_TargetList_allocbuf (
- corba_target->sources._maximum);
- corba_target->sources._release = CORBA_TRUE;
-
- for (lp = target->sources, i = 0; lp; lp = lp->next, i++)
- corba_target->sources._buffer [i] =
- CORBA_string_dup (((GbfAmTargetSource *) lp->data)->id);
-
- return corba_target;
+ trgt->group_id = NULL;
+
+ trgt->sources = NULL;
+ for (l = target->sources; l; l = l->next) {
+ GbfAmTargetSource *source = l->data;
+ trgt->sources = g_list_append (trgt->sources, g_strdup (source->id));
+ }
+
+ return trgt;
}
static void
foreach_target (gpointer key, gpointer value, gpointer data)
{
- GNOME_Development_SourceList *source_list;
+ GList **targets = data;
- source_list = data;
- source_list->_buffer[source_list->_length] = CORBA_string_dup (key);
- source_list->_length++;
+ *targets = g_list_append (*targets, key);
}
-static GNOME_Development_TargetList *
-impl_get_all_targets (PortableServer_Servant servant,
- CORBA_Environment *ev)
+static GList *
+impl_get_all_targets (GbfProject *project,
+ GError **error)
{
- GbfAmProject *prj;
- GbfAmProjectPrivate *priv;
- GNOME_Development_TargetList *target_list;
-
- prj = GBF_AM_PROJECT (bonobo_object_from_servant (servant));
- bonobo_return_val_if_fail (prj != NULL, NULL, ev);
- priv = prj->priv;
+ GbfAmProject *prj = GBF_AM_PROJECT (project);
+ GList *targets = NULL;
- target_list = GNOME_Development_TargetList__alloc ();
-
- target_list->_maximum = g_hash_table_size (priv->targets);
- target_list->_length = 0;
- target_list->_buffer = GNOME_Development_TargetList_allocbuf (target_list->_maximum);
- CORBA_sequence_set_release (target_list, CORBA_TRUE);
-
- g_hash_table_foreach (priv->targets, foreach_target, target_list);
+ g_hash_table_foreach (prj->priv->targets, foreach_target, &targets);
- return target_list;
+ return targets;
}
-static Bonobo_Control
-impl_configure_new_target (PortableServer_Servant servant,
- CORBA_Environment *ev)
+static GtkWidget *
+impl_configure_new_target (GbfProject *project,
+ GError **error)
{
- GbfAmProject *prj = GBF_AM_PROJECT (bonobo_object_from_servant (servant));
-
- prj = NULL;
+ UNIMPLEMENTED;
- return CORBA_OBJECT_NIL;
+ return NULL;
}
-static Bonobo_Control
-impl_configure_target (PortableServer_Servant servant,
- const CORBA_char *id,
- CORBA_Environment *ev)
+static GtkWidget *
+impl_configure_target (GbfProject *project,
+ const char *id,
+ GError **error)
{
- GbfAmProject *prj = GBF_AM_PROJECT (bonobo_object_from_servant (servant));
-
- prj = NULL;
+ UNIMPLEMENTED;
- return CORBA_OBJECT_NIL;
+ return NULL;
}
-static CORBA_char *
-impl_add_target (PortableServer_Servant servant,
- const CORBA_char *group_id,
- const CORBA_char *name,
- const CORBA_char *type,
- CORBA_Environment *ev)
+static const char *
+impl_add_target (GbfProject *project,
+ const char *group_id,
+ const char *name,
+ const char *type,
+ GError **error)
{
- GbfAmProject *prj = GBF_AM_PROJECT (bonobo_object_from_servant (servant));
-
- prj = NULL;
+ UNIMPLEMENTED;
return NULL;
}
static void
-impl_remove_target (PortableServer_Servant servant,
- const CORBA_char *id,
- CORBA_Environment *ev)
+impl_remove_target (GbfProject *project,
+ const char *id,
+ GError **error)
{
- GbfAmProject *prj = GBF_AM_PROJECT (bonobo_object_from_servant (servant));
-
- prj = NULL;
+ UNIMPLEMENTED;
}
-static CORBA_char *
-impl_name_for_type (PortableServer_Servant servant,
- const CORBA_char *type,
- CORBA_Environment *ev)
+static const char *
+impl_name_for_type (GbfProject *project,
+ const char *type)
{
- CORBA_char *type_name;
-
if (!strcmp (type, "static_lib")) {
- type_name = CORBA_string_dup ("Static Library");
+ return _("Static Library");
} else if (!strcmp (type, "shared_lib")) {
- type_name = CORBA_string_dup ("Shared Library");
+ return _("Shared Library");
} else if (!strcmp (type, "man")) {
- type_name = CORBA_string_dup ("Man Documentation");
+ return _("Man Documentation");
} else if (!strcmp (type, "data")) {
- type_name = CORBA_string_dup ("Miscellaneous Data");
+ return _("Miscellaneous Data");
} else if (!strcmp (type, "program")) {
- type_name = CORBA_string_dup ("Program");
+ return _("Program");
} else if (!strcmp (type, "script")) {
- type_name = CORBA_string_dup ("Script");
+ return _("Script");
} else if (!strcmp (type, "info")) {
- type_name = CORBA_string_dup ("Info Documenation");
+ return _("Info Documenation");
} else {
- type_name = CORBA_string_dup ("Unknown");
+ return _("Unknown");
}
-
- return type_name;
}
-static GNOME_Development_Icon *
-create_icon_from_pixbuf (GdkPixbuf *pixbuf)
+static GdkPixbuf *
+impl_icon_for_type (GbfProject *project,
+ const char *type)
{
- GNOME_Development_Icon *icon;
- const char *sp;
- CORBA_octet *dp;
- int width, height, total_width, rowstride;
- int i, j;
- gboolean has_alpha;
-
- icon = GNOME_Development_Icon__alloc ();
-
- width = gdk_pixbuf_get_width (pixbuf);
- height = gdk_pixbuf_get_height (pixbuf);
- rowstride = gdk_pixbuf_get_rowstride (pixbuf);
- has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
-
- if (has_alpha)
- total_width = 4 * width;
- else
- total_width = 3 * width;
-
- icon->width = width;
- icon->height = height;
- icon->hasAlpha = has_alpha;
-
- icon->rgbaData._length = icon->height * total_width;
- icon->rgbaData._maximum = icon->rgbaData._length;
- icon->rgbaData._buffer = CORBA_sequence_CORBA_octet_allocbuf (icon->rgbaData._maximum);
- icon->rgbaData._release = CORBA_TRUE;
-
- sp = gdk_pixbuf_get_pixels (pixbuf);
- dp = icon->rgbaData._buffer;
- for (i = 0; i < height; i ++) {
- for (j = 0; j < total_width; j++)
- *(dp ++) = sp[j];
- sp += rowstride;
- }
-
- return icon;
-}
-
-static GNOME_Development_Icon *
-impl_icon_for_type (PortableServer_Servant servant,
- const CORBA_char *type,
- CORBA_Environment *ev)
-{
- GNOME_Development_Icon *icon;
GdkPixbuf *pixbuf;
if (!strcmp (type, "static_lib")) {
@@ -2018,129 +1905,100 @@
pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **)unknown_xpm);
}
- icon = create_icon_from_pixbuf (pixbuf);
- gdk_pixbuf_unref (pixbuf);
-
- return icon;
+ return pixbuf;
}
-static GNOME_Development_TargetSource *
-impl_get_source (PortableServer_Servant servant,
- const CORBA_char *id,
- CORBA_Environment *ev)
+static GbfProjectTargetSource *
+impl_get_source (GbfProject *project,
+ const char *id,
+ GError **error)
{
- GbfAmProject *prj;
- GbfAmProjectPrivate *priv;
- GNOME_Development_TargetSource *corba_source;
+ GbfAmProject *prj = GBF_AM_PROJECT (project);
GbfAmTargetSource *source;
-
- prj = GBF_AM_PROJECT (bonobo_object_from_servant (servant));
- bonobo_return_val_if_fail (prj != NULL, NULL, ev);
- priv = prj->priv;
+ GbfProjectTargetSource *src;
- source = g_hash_table_lookup (priv->sources, id);
+ source = g_hash_table_lookup (prj->priv->sources, id);
if (source == NULL) {
- bonobo_exception_set (ev, ex_GNOME_Development_Project_DoesntExist);
- return CORBA_OBJECT_NIL;
+ if (error) {
+ *error = g_error_new (GBF_PROJECT_ERROR,
+ GBF_PROJECT_ERROR_DOESNT_EXIST,
+ _("Source doesn't exist"));
+ }
+ return NULL;
}
-
- corba_source = GNOME_Development_TargetSource__alloc ();
-
- corba_source->id = CORBA_string_dup (source->id);
+
+ src = g_new0 (GbfProjectTargetSource, 1);
+ src->id = g_strdup (source->id);
+ src->source_uri = g_strdup (source->uri);
+
if (source->target)
- corba_source->target_id = CORBA_string_dup (source->target->id);
+ src->target_id = g_strdup (source->target->id);
else
- corba_source->target_id = CORBA_string_dup (EMPTY_STRING);
-
- corba_source->source = CORBA_string_dup (source->uri);
-
- return corba_source;
+ src->target_id = NULL;
+
+ return src;
}
static void
foreach_source (gpointer key, gpointer value, gpointer data)
{
- GNOME_Development_SourceList *source_list;
+ GList **sources = data;
- source_list = data;
- source_list->_buffer [source_list->_length] = CORBA_string_dup (key);
- source_list->_length++;
+ *sources = g_list_append (*sources, key);
}
-static GNOME_Development_SourceList *
-impl_get_all_sources (PortableServer_Servant servant,
- CORBA_Environment *ev)
+static GList *
+impl_get_all_sources (GbfProject *project,
+ GError **error)
{
- GbfAmProject *prj;
- GbfAmProjectPrivate *priv;
- GNOME_Development_SourceList *source_list;
-
- prj = GBF_AM_PROJECT (bonobo_object_from_servant (servant));
- bonobo_return_val_if_fail (prj != NULL, NULL, ev);
- priv = prj->priv;
-
- source_list = GNOME_Development_SourceList__alloc ();
-
- source_list->_maximum = g_hash_table_size (priv->sources);
- source_list->_length = 0;
- source_list->_buffer = GNOME_Development_SourceList_allocbuf (
- source_list->_maximum);
- CORBA_sequence_set_release (source_list, CORBA_TRUE);
-
- g_hash_table_foreach (priv->sources, foreach_source, source_list);
+ GbfAmProject *prj = GBF_AM_PROJECT (project);
+ GList *sources = NULL;
+
+ g_hash_table_foreach (prj->priv->sources, foreach_source, &sources);
- return source_list;
+ return sources;
}
-static Bonobo_Control
-impl_configure_new_source (PortableServer_Servant servant,
- CORBA_Environment *ev)
+static GtkWidget *
+impl_configure_new_source (GbfProject *project,
+ GError **error)
{
- GbfAmProject *prj = GBF_AM_PROJECT (bonobo_object_from_servant (servant));
-
- prj = NULL;
+ UNIMPLEMENTED;
- return CORBA_OBJECT_NIL;
+ return NULL;
}
-static Bonobo_Control
-impl_configure_source (PortableServer_Servant servant,
- const CORBA_char *id,
- CORBA_Environment *ev)
+static GtkWidget *
+impl_configure_source (GbfProject *project,
+ const char *id,
+ GError **error)
{
- GbfAmProject *prj = GBF_AM_PROJECT (bonobo_object_from_servant (servant));
-
- prj = NULL;
+ UNIMPLEMENTED;
- return CORBA_OBJECT_NIL;
+ return NULL;
}
/**
* impl_add_source:
- * @servant:
+ * @project:
* @target_id: the target ID to where to add the source
* @uri: the FULL uri to the file.
- * @ev:
+ * @error:
*
* Add source implementation. The uri must have the project root as its parent.
*
* Return value:
**/
-static CORBA_char *
-impl_add_source (PortableServer_Servant servant,
- const CORBA_char *target_id,
- const CORBA_char *uri,
- CORBA_Environment *ev)
+static const char *
+impl_add_source (GbfProject *project,
+ const char *target_id,
+ const char *uri,
+ GError **error)
{
- GbfAmProject *prj;
- GbfAmProjectPrivate *priv;
+ GbfAmProject *prj = GBF_AM_PROJECT (project);
GbfAmTargetSource *source;
xmlDocPtr doc;
char id[1024];
-
- prj = GBF_AM_PROJECT (bonobo_object_from_servant (servant));
- bonobo_return_val_if_fail (prj != NULL, NULL, ev);
- priv = prj->priv;
/* FIXME: check that the source is inside the project dir */
@@ -2154,15 +2012,19 @@
/* Compute the id */
g_snprintf (id, 1024, "%s%s", target_id, source->uri);
source->id = g_strdup (id);
- source->target = g_hash_table_lookup (priv->targets, target_id);
-
- /* --- */
-
+ source->target = g_hash_table_lookup (prj->priv->targets, target_id);
+
/* Create the update xml */
doc = create_change_xml (prj);
- if (!write_add_source (prj, doc, source))
- bonobo_exception_set (ev, ex_GNOME_Development_Project_DoesntExist);
+ if (!write_add_source (prj, doc, source)) {
+ if (error) {
+ *error = g_error_new (GBF_PROJECT_ERROR,
+ GBF_PROJECT_ERROR_DOESNT_EXIST,
+ _("Source couldn't be added"));
+ }
+ return NULL;
+ }
#if 1
xmlSetDocCompressMode (doc, 0);
@@ -2170,50 +2032,62 @@
#endif
/* Update the project */
- if (update_project (doc, priv->project_dir) != 0) {
- bonobo_exception_set (ev, ex_GNOME_Development_Project_Malformed);
+ if (update_project (doc, prj->priv->project_dir) != 0) {
+ if (error) {
+ *error = g_error_new (GBF_PROJECT_ERROR,
+ GBF_PROJECT_ERROR_PROJECT_MALFORMED,
+ _("Unable to update project"));
+ }
return NULL;
}
-
- return CORBA_string_dup (source->id);
+
+ return source->id;
}
static void
-impl_remove_source (PortableServer_Servant servant,
- const CORBA_char *id,
- CORBA_Environment *ev)
+impl_remove_source (GbfProject *project,
+ const char *id,
+ GError **error)
{
- GbfAmProject *prj;
- GbfAmProjectPrivate *priv;
+ GbfAmProject *prj = GBF_AM_PROJECT (project);
GbfAmTargetSource *source;
xmlDocPtr doc;
-
- prj = GBF_AM_PROJECT (bonobo_object_from_servant (servant));
- bonobo_return_if_fail (prj != NULL, ev);
- priv = prj->priv;
-
+
/* Find the source */
- source = g_hash_table_lookup (priv->sources, id);
+ source = g_hash_table_lookup (prj->priv->sources, id);
if (source == NULL) {
- bonobo_exception_set (ev, ex_GNOME_Development_Project_DoesntExist);
+ if (error) {
+ *error = g_error_new (GBF_PROJECT_ERROR,
+ GBF_PROJECT_ERROR_DOESNT_EXIST,
+ _("Source doesn't exist"));
+ }
return;
}
-
+
/* Create the update xml */
doc = create_change_xml (prj);
if (!write_remove_source (prj, doc, source)) {
- bonobo_exception_set (ev, ex_GNOME_Development_Project_DoesntExist);
+ if (error) {
+ *error = g_error_new (GBF_PROJECT_ERROR,
+ GBF_PROJECT_ERROR_DOESNT_EXIST,
+ _("Source coudn't be removed"));
+ }
return;
}
-
+
#if 1
xmlSetDocCompressMode (doc, 0);
xmlSaveFile ("/tmp/remove-source.xml", doc);
#endif
/* Update the project */
- if (update_project (doc, priv->project_dir) != 0)
- bonobo_exception_set (ev, ex_GNOME_Development_Project_Malformed);
+ if (update_project (doc, prj->priv->project_dir) != 0) {
+ if (error) {
+ *error = g_error_new (GBF_PROJECT_ERROR,
+ GBF_PROJECT_ERROR_PROJECT_MALFORMED,
+ _("Unable to update project"));
+ }
+ }
}
static void
@@ -2221,7 +2095,7 @@
{
GbfAmProject *prj;
GbfAmProjectPrivate *priv;
-
+
g_return_if_fail (object != NULL);
g_return_if_fail (GBF_IS_AM_PROJECT (object));
@@ -2233,117 +2107,89 @@
g_free (priv->buffer);
priv->buffer = NULL;
}
-
- BONOBO_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
+
+ GNOME_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
+}
+
+static void
+gbf_am_project_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GbfAmProject *project = GBF_AM_PROJECT (object);
+
+ switch (prop_id) {
+ case PROP_PROJECT_DIR:
+ g_value_set_string (value, project->priv->project_dir);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
gbf_am_project_class_init (GbfAmProjectClass *klass)
{
GObjectClass *object_class;
- POA_GNOME_Development_Project__epv *epv = &klass->epv;
+ GbfProjectClass *project_class;
object_class = G_OBJECT_CLASS (klass);
- parent_class = gtk_type_class (PARENT_TYPE);
+ project_class = GBF_PROJECT_CLASS (klass);
+ parent_class = g_type_class_peek_parent (klass);
object_class->dispose = gbf_am_project_dispose;
-
- epv->load = impl_load;
- epv->build = impl_build;
- epv->getGroup = impl_get_group;
- epv->configureNewGroup = impl_configure_new_group;
- epv->configureGroup = impl_configure_group;
- epv->addGroup = impl_add_group;
- epv->removeGroup = impl_remove_group;
- epv->nameForType = impl_name_for_type;
- epv->iconForType = impl_icon_for_type;
- epv->getTarget = impl_get_target;
- epv->getAllTargets = impl_get_all_targets;
- epv->configureNewTarget = impl_configure_new_target;
- epv->configureTarget = impl_configure_target;
- epv->addTarget = impl_add_target;
- epv->removeTarget = impl_remove_target;
- epv->getSource = impl_get_source;
- epv->getAllSources = impl_get_all_sources;
- epv->configureNewSource = impl_configure_new_source;
- epv->configureSource = impl_configure_source;
- epv->addSource = impl_add_source;
- epv->removeSource = impl_remove_source;
+ object_class->get_property = gbf_am_project_get_property;
+
+ project_class->load = impl_load;
+ project_class->build = impl_build;
+ project_class->add_group = impl_add_group;
+ project_class->remove_group = impl_remove_group;
+ project_class->get_group = impl_get_group;
+ project_class->configure_group = impl_configure_group;
+ project_class->configure_new_group = impl_configure_new_group;
+ project_class->add_target = impl_add_target;
+ project_class->remove_target = impl_remove_target;
+ project_class->get_target = impl_get_target;
+ project_class->get_all_targets = impl_get_all_targets;
+ project_class->configure_target = impl_configure_target;
+ project_class->configure_new_target = impl_configure_new_target;
+ project_class->add_source = impl_add_source;
+ project_class->remove_source = impl_remove_source;
+ project_class->get_source = impl_get_source;
+ project_class->get_all_sources = impl_get_all_sources;
+ project_class->configure_source = impl_configure_source;
+ project_class->configure_new_source = impl_configure_new_source;
+ project_class->name_for_type = impl_name_for_type;
+ project_class->icon_for_type = impl_icon_for_type;
+
+ g_object_class_install_property
+ (object_class, PROP_PROJECT_DIR,
+ g_param_spec_string ("project-dir",
+ _("Project directory"),
+ _("Project directory"),
+ "",
+ G_PARAM_READABLE));
}
static void
-gbf_am_project_init (GbfAmProject *prj)
+gbf_am_project_instance_init (GbfAmProject *prj)
{
GbfAmProjectPrivate *priv;
priv = g_new0 (GbfAmProjectPrivate, 1);
-
prj->priv = priv;
project_init (prj);
-
- /* setup aggregate interfaces */
- priv->event_source = bonobo_event_source_new ();
- bonobo_object_add_interface (BONOBO_OBJECT (prj),
- BONOBO_OBJECT (priv->event_source));
-
- priv->property_bag = bonobo_property_bag_new (gbf_am_project_get_prop,
- gbf_am_project_set_prop,
- prj);
- bonobo_property_bag_add (priv->property_bag, "project-dir",
- PROP_PROJECT_DIR, BONOBO_ARG_STRING,
- NULL, "The top-level project directory", 0);
- bonobo_object_add_interface (BONOBO_OBJECT (prj),
- BONOBO_OBJECT (priv->property_bag));
-}
-
-/*
- * Property bag methods -----------------------------
- */
-
-static void
-gbf_am_project_get_prop (BonoboPropertyBag *bag, BonoboArg *arg,
- guint arg_id, CORBA_Environment *ev,
- gpointer data)
-{
- GbfAmProject *prj;
- GbfAmProjectPrivate *priv;
-
- prj = data;
- priv = prj->priv;
-
- switch (arg_id) {
- case PROP_PROJECT_DIR:
- BONOBO_ARG_SET_STRING (arg, priv->project_dir);
- break;
- }
-}
-
-static void
-gbf_am_project_set_prop (BonoboPropertyBag *bag, const BonoboArg *arg,
- guint arg_id, CORBA_Environment *ev,
- gpointer data)
-{
- GbfAmProject *prj;
- GbfAmProjectPrivate *priv;
-
- prj = data;
- priv = prj->priv;
-
- switch (arg_id) {
- case PROP_PROJECT_DIR:
- break;
- }
}
-
-BONOBO_TYPE_FUNC_FULL (GbfAmProject, GNOME_Development_Project, PARENT_TYPE, gbf_am_project);
-
-
GbfAmProject *
gbf_am_project_new (void)
{
- g_message ("Creating project object");
-
return GBF_AM_PROJECT (g_object_new (GBF_TYPE_AM_PROJECT, NULL));
}
+
+GBF_BACKEND_BOILERPLATE (GbfAmProject, gbf_am_project);
+
+GBF_SIMPLE_BACKEND (GbfAmProject, gbf_am_project);
Index: src/backends/libgbf_am/gbf-am-project.h
===================================================================
RCS file: /cvs/gnome/gnome-build/src/backends/libgbf_am/gbf-am-project.h,v
retrieving revision 1.9
diff -u -r1.9 gbf-am-project.h
--- src/backends/libgbf_am/gbf-am-project.h 23 Feb 2002 05:30:37 -0000 1.9
+++ src/backends/libgbf_am/gbf-am-project.h 23 Aug 2002 12:59:48 -0000
@@ -24,36 +24,33 @@
#ifndef _GBF_AM_PROJECT_H_
#define _GBF_AM_PROJECT_H_
-#include <bonobo/bonobo-object.h>
-#include "gnome-build.h"
+#include <glib-object.h>
+#include "gbf-project.h"
+#include "glue-plugin.h"
G_BEGIN_DECLS
-#define GBF_TYPE_AM_PROJECT (gbf_am_project_get_type ())
-#define GBF_AM_PROJECT(obj) (GTK_CHECK_CAST ((obj), GBF_TYPE_AM_PROJECT, GbfAmProject))
-#define GBF_AM_PROJECT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GBF_TYPE_AM_PROJECT, GbfAmProjectClass))
-#define GBF_IS_AM_PROJECT(obj) (GTK_CHECK_TYPE ((obj), GBF_TYPE_AM_PROJECT))
-#define GBF_IS_AM_PROJECT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), GBF_TYPE_AM_PROJECT))
-
+#define GBF_TYPE_AM_PROJECT (gbf_am_project_get_type (NULL))
+#define GBF_AM_PROJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GBF_TYPE_AM_PROJECT, GbfAmProject))
+#define GBF_AM_PROJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GBF_TYPE_AM_PROJECT, GbfAmProjectClass))
+#define GBF_IS_AM_PROJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GBF_TYPE_AM_PROJECT))
+#define GBF_IS_AM_PROJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GBF_TYPE_AM_PROJECT))
typedef struct _GbfAmProject GbfAmProject;
typedef struct _GbfAmProjectPrivate GbfAmProjectPrivate;
typedef struct _GbfAmProjectClass GbfAmProjectClass;
struct _GbfAmProject {
- BonoboObject parent;
+ GbfProject parent;
GbfAmProjectPrivate *priv;
};
struct _GbfAmProjectClass {
- BonoboObjectClass parent_class;
-
- POA_GNOME_Development_Project__epv epv;
+ GbfProjectClass parent_class;
};
-
-GType gbf_am_project_get_type (void);
+GType gbf_am_project_get_type (GluePlugin *plugin);
GbfAmProject *gbf_am_project_new (void);
G_END_DECLS
Index: src/backends/libgbf_am/test.c
===================================================================
RCS file: /cvs/gnome/gnome-build/src/backends/libgbf_am/test.c,v
retrieving revision 1.4
diff -u -r1.4 test.c
--- src/backends/libgbf_am/test.c 12 Jul 2002 04:38:46 -0000 1.4
+++ src/backends/libgbf_am/test.c 23 Aug 2002 12:59:48 -0000
@@ -1,197 +1,71 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* gbf-am-project.c
- *
- * Copyright (C) 2000 JP Rosevear
- *
- * 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.
- *
- * 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: JP Rosevear
- */
-
#include <config.h>
#include <gnome.h>
-#include <bonobo.h>
-#include <bonobo-activation/bonobo-activation.h>
-#include "gnome-build.h"
+#include "gbf-backend.h"
-static GNOME_Development_Project
-activate_id (const char *id)
-{
- CORBA_Object object = CORBA_OBJECT_NIL;
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
-
- object = bonobo_activation_activate_from_id (id, Bonobo_ACTIVATION_FLAG_PRIVATE, NULL, &ev);
-
- if (BONOBO_EX (&ev))
- g_error ("Unable to activate object");
-
- CORBA_exception_free (&ev);
-
- return (GNOME_Development_Project) object;
-}
-
-static void
-print_group (GNOME_Development_Project project,
- gint depth,
- CORBA_char *group_id)
+int
+main (int argc, char *argv[])
{
- GNOME_Development_Group *group;
- CORBA_Environment ev;
- int i;
-
- CORBA_exception_init (&ev);
-
- group = GNOME_Development_Project_getGroup (project, group_id, &ev);
- if (!BONOBO_EX (&ev)) {
- for (i = 0; i < depth; i++)
- g_print (" ");
-
- g_print ("%s\n", group->name);
- for (i = 0; i < group->groups._length; i++)
- print_group (project, depth + 1, group->groups._buffer [i]);
+ GSList *l;
+ GbfBackend *backend;
+ GbfProject *project;
+ GList *sources, *targets;
+
+ gnome_program_init ("libgbf-am-test", VERSION, LIBGNOME_MODULE,
+ argc, argv, NULL);
+
+#if 0
+ if (argc == 1) {
+ g_print ("you need to specify a project path\n");
+ return 0;
+ }
+#endif
+
+ g_print ("initializing gbf backend...\n");
+ gbf_backend_init ();
- CORBA_free (group);
+ for (l = gbf_backend_get_backends (); l; l = l->next) {
+ backend = l->data;
+ if (!strcmp (backend->id, "gbf-am:GbfAmProject"))
+ break;
+ backend = NULL;
}
- CORBA_exception_free (&ev);
-}
+ if (!backend) {
+ g_print ("no automake/autoconf backend available\n");
+ return 0;
+ }
-int
-main (int argc, char *argv[])
-{
- GNOME_Development_Project project;
- Bonobo_ServerInfoList *result;
- GNOME_Development_SourceList *source_list;
- GNOME_Development_TargetList *target_list;
- CORBA_char *remove_id = NULL;
- CORBA_char *target_id = NULL;
- CORBA_char *uri = NULL;
- CORBA_Environment ev;
- int i;
-
- gnome_program_init ("test-gbf-libgbf-am-backend", VERSION, LIBGNOME_MODULE,
- argc, argv, GNOME_PARAM_POPT_TABLE,
- bonobo_activation_popt_options, NULL);
-
- CORBA_exception_init (&ev);
-
- /* Get a project */
- result = bonobo_activation_query ("repo_ids.has ('IDL:GNOME/Development/Build:1.0')", NULL, &ev);
-
- if (BONOBO_EX (&ev)) {
- g_error ("Unable to activate GNOME_Development_Build\n");
- return -1;
- }
-
- g_print ("Activation ID: %s\n", result->_buffer[0].iid);
-
- project = activate_id (result->_buffer[0].iid);
- if (project == CORBA_OBJECT_NIL)
- return -1;
-
- CORBA_free (result);
-
- /* Do stuff with it */
- if (argc > 1)
- GNOME_Development_Project_load (project, argv [1], &ev);
- if (BONOBO_EX (&ev))
- g_error ("Unable to load project");
+ g_print ("creating new gbf-am project\n");
+ project = gbf_backend_new_project (backend->id);
+ if (!project) {
+ g_print ("project creation failed\n");
+ return 0;
+ }
+
+ g_print ("loading project %s\n\n", ""/*argv[1]*/);
+ GBF_PROJECT_GET_CLASS (project)->load (project, "/home/jeroen/Projects/gtksourceview", NULL);
g_print ("*** Sources\n\n");
- source_list = GNOME_Development_Project_getAllSources (project, &ev);
- if (BONOBO_EX (&ev)) {
- g_error ("Unable to get sources");
- } else {
- for (i = 0; i < source_list->_length; i++) {
- GNOME_Development_TargetSource *source;
-
- source = GNOME_Development_Project_getSource (project, source_list->_buffer[i], &ev);
- if (!BONOBO_EX (&ev)) {
- g_print ("%s\n", source->source);
- CORBA_free (source);
- }
- }
- CORBA_free (source_list);
+ sources = GBF_PROJECT_GET_CLASS (project)->get_all_sources (project, NULL);
+
+ for (l = sources; l; l = l->next) {
+ const char *source = l->data;
+ g_print ("%s\n", source);
+ }
+
+#if 0
+ g_print ("\n\n*** Targets\n\n");
+ targets = GBF_PROJECT_GET_CLASS (project)->get_all_targets (project, NULL);
+
+ for (l = targets; l; l = l->next) {
+ const char *target = l->data;
+ g_print ("%s\n", target);
}
+#endif
g_print ("\n\n");
- g_print ("*** Targets\n\n");
- target_list = GNOME_Development_Project_getAllTargets (project, &ev);
- if (BONOBO_EX (&ev)) {
- g_error ("Unable to get targets");
- } else {
- int j;
- for (i = 0; i < target_list->_length; i++) {
- GNOME_Development_Target *target;
-
- target = GNOME_Development_Project_getTarget (project, target_list->_buffer[i], &ev);
- if (!BONOBO_EX (&ev))
- g_print ("%s [%s]\n", target->name, target_list->_buffer [i]);
-
- for (j = 0; j < target->sources._length; j++) {
- GNOME_Development_TargetSource *source;
- const CORBA_char *id;
-
- id = target->sources._buffer[j];
-
- source = GNOME_Development_Project_getSource (project, id, &ev);
- if (!BONOBO_EX (&ev)) {
- g_print (" %s\n", source->source);
-
- if (remove_id == NULL && !strcmp (target->type, "program")) {
- /* we need a source from a program, since other target
- writers are still not implemented */
- target_id = CORBA_string_dup (source->target_id);
- uri = CORBA_string_dup (source->source);
- remove_id = CORBA_string_dup (id);
- }
- }
-
- CORBA_free (source);
- }
- CORBA_free (target);
- }
- CORBA_free (target_list);
- }
-
- g_print ("\n\n*** Groups\n\n");
- print_group (project, 0, "/");
-
- GNOME_Development_Project_removeSource (project, remove_id, &ev);
- if (BONOBO_EX (&ev))
- g_error ("Unable to remove source");
- else
- g_print ("Removed source\n");
- CORBA_free (remove_id);
-
- GNOME_Development_Project_addSource (project, target_id, uri, &ev);
- if (BONOBO_EX (&ev))
- g_error ("Unable to add source");
- else
- g_print ("Added source\n");
- CORBA_free (target_id);
-
- /* Clean up */
- bonobo_object_release_unref (project, &ev);
- if (BONOBO_EX (&ev))
- g_error ("Unable to unref object");
-
- CORBA_exception_free (&ev);
+ g_print ("unreffing project\n");
+ g_object_unref (project);
- return 0;
+ return 0;
}
Index: src/controls/Makefile.am
===================================================================
RCS file: /cvs/gnome/gnome-build/src/controls/Makefile.am,v
retrieving revision 1.22
diff -u -r1.22 Makefile.am
--- src/controls/Makefile.am 12 Jul 2002 04:38:50 -0000 1.22
+++ src/controls/Makefile.am 23 Aug 2002 12:59:48 -0000
@@ -14,17 +14,12 @@
lib_LTLIBRARIES = libgbf-widgets-1.la
libgbf_widgets_1_la_SOURCES = \
- control-factories.c \
- commands.c \
- commands.h \
default-icon.c \
default-icon.h \
gbf-project-tree.c \
gbf-target-tree.c \
gbf-tree-data.c \
gbf-build-info.c \
- menus.c \
- menus.h \
utils.c \
utils.h
@@ -47,6 +42,7 @@
test_controls_LDADD = \
$(top_builddir)/src/lib/libgbf-1.la \
+ libgbf-widgets-1.la \
$(GBF_CONTROL_LIBS)
uidir = $(datadir)/gnome-2.0/ui
Index: src/controls/gbf-build-info.c
===================================================================
RCS file: /cvs/gnome/gnome-build/src/controls/gbf-build-info.c,v
retrieving revision 1.14
diff -u -r1.14 gbf-build-info.c
--- src/controls/gbf-build-info.c 12 Jul 2002 04:38:50 -0000 1.14
+++ src/controls/gbf-build-info.c 23 Aug 2002 12:59:49 -0000
@@ -21,10 +21,17 @@
* Author: JP Rosevear
*/
-#include <bonobo/bonobo-exception.h>
+#include <libgnome/gnome-i18n.h>
+#include <libgnome/gnome-macros.h>
#include <libgtkhtml/gtkhtml.h>
#include "utils.h"
#include "gbf-build-info.h"
+#include "gbf-project.h"
+
+enum {
+ ERROR_SELECTED,
+ LAST_SIGNAL
+};
enum {
PROP_0,
@@ -32,60 +39,60 @@
};
struct _GbfBuildInfoPrivate {
- GNOME_Development_Project prj;
+ GbfProject *prj;
GtkWidget *html;
HtmlDocument *html_doc;
-
- BonoboListener *listener;
-
- BonoboEventSource *event_source;
};
-static GtkVBoxClass *parent_class = NULL;
+static guint info_signals [LAST_SIGNAL] = { 0 };
-static void class_init (GbfBuildInfoClass *klass);
-static void init (GbfBuildInfo *info);
static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
static void set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void destroy (GtkObject *object);
+static void dispose (GObject *object);
-static void event_cb (BonoboListener *listener,
- const char *event,
- CORBA_any *any,
- CORBA_Environment *ev,
- gpointer user_data);
-
static void link_clicked_cb (HtmlDocument *document,
const gchar *url,
gpointer user_data);
+GNOME_CLASS_BOILERPLATE (GbfBuildInfo, gbf_build_info, GtkVBox, GTK_TYPE_VBOX);
+
static void
-class_init (GbfBuildInfoClass *klass)
+gbf_build_info_class_init (GbfBuildInfoClass *klass)
{
GObjectClass *g_object_class;
- GtkObjectClass *object_class;
g_object_class = G_OBJECT_CLASS (klass);
- object_class = (GtkObjectClass *) klass;
parent_class = g_type_class_peek_parent (klass);
+ g_object_class->dispose = dispose;
g_object_class->get_property = get_property;
g_object_class->set_property = set_property;
- object_class->destroy = destroy;
-
g_object_class_install_property
(g_object_class, PROP_PROJECT,
g_param_spec_pointer ("project",
_("Project"),
_("Corba Project Object"),
G_PARAM_READWRITE));
+
+ info_signals [ERROR_SELECTED] =
+ g_signal_new ("error_selected",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GbfBuildInfoClass, error_selected),
+ NULL, /* accumulator */
+ NULL, /* accu_data */
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, /* return type */
+ 2,
+ G_TYPE_STRING,
+ G_TYPE_INT);
}
static void
-init (GbfBuildInfo *info)
+gbf_build_info_instance_init (GbfBuildInfo *info)
{
GbfBuildInfoPrivate *priv;
GtkWidget *scrolled_window;
@@ -119,8 +126,6 @@
gtk_container_add (GTK_CONTAINER (scrolled_window), priv->html);
gtk_container_add (GTK_CONTAINER (info), scrolled_window);
-
- priv->event_source = bonobo_event_source_new ();
}
static void
@@ -133,7 +138,7 @@
switch (prop_id) {
case PROP_PROJECT:
- g_value_set_pointer (value, gbf_build_info_get_project (info));
+ g_value_set_pointer (value, info->priv->prj);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -151,7 +156,7 @@
switch (prop_id) {
case PROP_PROJECT:
- gbf_build_info_set_project (info, g_value_get_pointer (value));
+ info->priv->prj = g_value_get_pointer (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -160,30 +165,23 @@
}
static void
-destroy (GtkObject *object)
+dispose (GObject *object)
{
GbfBuildInfo *info;
GbfBuildInfoPrivate *priv;
- CORBA_Environment ev;
-
+
info = GBF_BUILD_INFO (object);
priv = info->priv;
-
- if (priv) {
- CORBA_exception_init (&ev);
- priv->prj = bonobo_object_release_unref (priv->prj, &ev);
-
- CORBA_exception_free (&ev);
+ if (priv) {
+ if (priv->prj)
+ g_object_unref (priv->prj);
/* FIXME: destroy the html objects */
g_free (priv);
info->priv = NULL;
}
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
@@ -203,6 +201,7 @@
g_free (html);
}
+#if 0
static void
file_msg (GbfBuildInfo *info, CORBA_any *any)
{
@@ -214,7 +213,7 @@
source = any->_value;
- basename = uri_basename (source);
+ basename = uri_basename (source);
html = g_strdup_printf ("<p>Compiling <a href=\"%s\">%s</a></p>",
source, basename);
html_document_write_stream (priv->html_doc, html, strlen(html));
@@ -247,6 +246,7 @@
g_free (html);
g_free (basename);
}
+#endif
static void
end_msg (GbfBuildInfo *info)
@@ -263,6 +263,7 @@
html_document_close_stream (priv->html_doc);
}
+#if 0
static void
event_cb (BonoboListener *listener,
const char *event,
@@ -284,12 +285,14 @@
else if (!strcmp (event, "build-error"))
error_msg (info, any);
}
+#endif
static void
link_clicked_cb (HtmlDocument *document,
const gchar *url,
gpointer user_data)
{
+#if 0
GbfBuildInfo *info = GBF_BUILD_INFO (user_data);
GbfBuildInfoPrivate *priv;
GNOME_Development_Source source;
@@ -322,6 +325,7 @@
bonobo_event_source_notify_listeners (priv->event_source, type, arg, NULL);
bonobo_arg_release (arg);
+#endif
}
/* ----------------------------------------------------------------------
@@ -334,40 +338,7 @@
return GTK_WIDGET (g_object_new (GBF_TYPE_BUILD_INFO, NULL));
}
-GType
-gbf_build_info_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- GTypeInfo info = {
- sizeof (GbfBuildInfoClass),
- NULL, /* base_init. */
- NULL, /* base_finalize. */
- (GClassInitFunc) class_init,
- NULL, /* class_finalize. */
- NULL, /* class_data. */
- sizeof (GbfBuildInfo),
- 0, /* n_preallocs. */
- (GInstanceInitFunc) init,
- NULL, /* value_table. */
- };
-
- type = g_type_register_static (GTK_TYPE_VBOX, "GbfBuildInfo", &info, 0);
- }
-
- return type;
-}
-
-GNOME_Development_Project
-gbf_build_info_get_project (GbfBuildInfo *info)
-{
- g_return_val_if_fail (info != NULL, NULL);
- g_return_val_if_fail (GBF_IS_BUILD_INFO (info), NULL);
-
- return info->priv->prj;
-}
-
+#if 0
void
gbf_build_info_set_project (GbfBuildInfo *info, GNOME_Development_Project prj)
{
@@ -408,9 +379,4 @@
CORBA_exception_free (&ev);
}
-
-BonoboEventSource *
-gbf_build_info_get_event_source (GbfBuildInfo *info)
-{
- return info->priv->event_source;
-}
+#endif
Index: src/controls/gbf-build-info.h
===================================================================
RCS file: /cvs/gnome/gnome-build/src/controls/gbf-build-info.h,v
retrieving revision 1.3
diff -u -r1.3 gbf-build-info.h
--- src/controls/gbf-build-info.h 22 Feb 2002 01:41:32 -0000 1.3
+++ src/controls/gbf-build-info.h 23 Aug 2002 12:59:49 -0000
@@ -24,14 +24,9 @@
#ifndef _GBF_BUILD_INFO_H_
#define _GBF_BUILD_INFO_H_
-#include <gnome.h>
-#include <bonobo/bonobo-event-source.h>
-#include "gnome-build.h"
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
#define GBF_TYPE_BUILD_INFO (gbf_build_info_get_type ())
#define GBF_BUILD_INFO(obj) (GTK_CHECK_CAST ((obj), GBF_TYPE_BUILD_INFO, GbfBuildInfo))
@@ -51,17 +46,13 @@
struct _GbfBuildInfoClass {
GtkVBoxClass parent_class;
+
+ void (* error_selected) (GbfBuildInfo *info, const char *filename, int line);
};
-GType gbf_build_info_get_type (void);
-GtkWidget *gbf_build_info_new (void);
-GNOME_Development_Project gbf_build_info_get_project (GbfBuildInfo *info);
-void gbf_build_info_set_project (GbfBuildInfo *info,
- GNOME_Development_Project project);
-BonoboEventSource *gbf_build_info_get_event_source (GbfBuildInfo *info);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+GType gbf_build_info_get_type (void);
+GtkWidget *gbf_build_info_new (void);
+
+G_END_DECLS
#endif /* _GBF_BUILD_INFO_H_ */
Index: src/controls/gbf-project-tree.c
===================================================================
RCS file: /cvs/gnome/gnome-build/src/controls/gbf-project-tree.c,v
retrieving revision 1.31
diff -u -r1.31 gbf-project-tree.c
--- src/controls/gbf-project-tree.c 12 Jul 2002 04:38:50 -0000 1.31
+++ src/controls/gbf-project-tree.c 23 Aug 2002 12:59:49 -0000
@@ -21,18 +21,23 @@
* Author: JP Rosevear
*/
-#include <bonobo/bonobo-exception.h>
-#include <bonobo/bonobo-property-bag-client.h>
+#include <string.h>
+#include <gtk/gtktreeview.h>
+#include <libgnome/gnome-i18n.h>
+#include <libgnome/gnome-macros.h>
#include <libgnomevfs/gnome-vfs-types.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
-#include <gtk/gtktreeview.h>
-#include <libgnome/gnome-i18n.h>
-#include <string.h>
#include <gdl/gdl-icons.h>
#include "utils.h"
#include "gbf-tree-data.h"
#include "gbf-project-tree.h"
+#include "gbf-project.h"
+
+enum {
+ FILE_SELECTED,
+ LAST_SIGNAL
+};
enum Properties {
PROP_0,
@@ -40,7 +45,7 @@
};
struct _GbfProjectTreePrivate {
- GNOME_Development_Project prj;
+ GbfProject *prj;
GtkWidget *tree_sw;
GtkWidget *tree;
@@ -50,20 +55,14 @@
GnomeVFSURI *root;
GHashTable *dirs;
- BonoboListener *listener;
-
- BonoboEventSource *event_source;
-
GbfTreeData *empty_node;
};
-static GtkVBoxClass *parent_class = NULL;
+static guint tree_signals [LAST_SIGNAL] = { 0 };
-static void class_init (GbfProjectTreeClass *klass);
-static void init (GbfProjectTree *tree);
static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
static void set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void destroy (GtkObject *object);
+static void dispose (GObject *object);
static void set_pixbuf (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
GtkTreeModel *model, GtkTreeIter *iter,
@@ -71,12 +70,8 @@
static void set_text (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
GtkTreeModel *model, GtkTreeIter *iter,
gpointer data);
-
-static void event_cb (BonoboListener *listener,
- const char *event,
- CORBA_any *any,
- CORBA_Environment *ev,
- gpointer user_data);
+
+static void load_data (GbfProjectTree *tree);
static void row_activated_cb (GtkTreeView *tree_view,
GtkTreePath *path,
@@ -84,33 +79,43 @@
gpointer user_data);
static void insert_no_project_node (GbfProjectTree *tree);
+GNOME_CLASS_BOILERPLATE (GbfProjectTree, gbf_project_tree, GtkVBox, GTK_TYPE_VBOX);
+
static void
-class_init (GbfProjectTreeClass *klass)
+gbf_project_tree_class_init (GbfProjectTreeClass *klass)
{
GObjectClass *g_object_class;
- GtkObjectClass *object_class;
g_object_class = G_OBJECT_CLASS (klass);
- object_class = (GtkObjectClass *) klass;
parent_class = g_type_class_peek_parent (klass);
+ g_object_class->dispose = dispose;
g_object_class->get_property = get_property;
g_object_class->set_property = set_property;
- object_class->destroy = destroy;
-
g_object_class_install_property
(g_object_class, PROP_PROJECT,
g_param_spec_pointer ("project",
_("Project"),
- _("Corba Project Object"),
+ _("Project Object"),
G_PARAM_READWRITE));
+ tree_signals [FILE_SELECTED] =
+ g_signal_new ("file_selected",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GbfProjectTreeClass, file_selected),
+ NULL, /* accumulator */
+ NULL, /* accu_data */
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, /* return type */
+ 1,
+ G_TYPE_STRING);
}
static void
-init (GbfProjectTree *tree)
+gbf_project_tree_instance_init (GbfProjectTree *tree)
{
GbfProjectTreePrivate *priv;
GtkCellRenderer *renderer;
@@ -119,6 +124,7 @@
priv = g_new0 (GbfProjectTreePrivate, 1);
tree->priv = priv;
+ priv->prj = NULL;
/* create tree model. */
priv->tree_model =
@@ -163,8 +169,6 @@
priv->dirs = g_hash_table_new (g_str_hash, g_str_equal);
- priv->event_source = bonobo_event_source_new ();
-
priv->empty_node = gbf_tree_data_new (GBF_TREE_NODE_STRING,
_("No project loaded."));
insert_no_project_node (tree);
@@ -178,7 +182,7 @@
switch (prop_id) {
case PROP_PROJECT:
- g_value_set_pointer (value, gbf_project_tree_get_project (tree));
+ g_value_set_pointer (value, tree->priv->prj);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -191,10 +195,22 @@
const GValue *value, GParamSpec *pspec)
{
GbfProjectTree *tree = GBF_PROJECT_TREE (object);
+ char *dir;
switch (prop_id) {
case PROP_PROJECT:
- gbf_project_tree_set_project (tree, g_value_get_pointer (value));
+ if (tree->priv->root) {
+ gnome_vfs_uri_unref (tree->priv->root);
+ tree->priv->root = NULL;
+ }
+
+ tree->priv->prj = g_value_get_pointer (value);
+ if (tree->priv->prj) {
+ g_object_get (G_OBJECT (tree->priv->prj), "project-dir", &dir, NULL);
+ tree->priv->root = gnome_vfs_uri_new (dir);
+ }
+
+ load_data (tree);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -203,7 +219,7 @@
}
static void
-destroy (GtkObject *object)
+dispose (GObject *object)
{
GbfProjectTree *tree;
GbfProjectTreePrivate *priv;
@@ -212,8 +228,8 @@
priv = tree->priv;
if (priv) {
- if (priv->prj != CORBA_OBJECT_NIL)
- gbf_project_tree_set_project (tree, CORBA_OBJECT_NIL);
+ if (priv->prj != NULL)
+ g_object_unref (tree->priv->prj);
if (priv->empty_node) {
gbf_tree_data_free (priv->empty_node);
@@ -223,9 +239,6 @@
g_free (priv);
tree->priv = NULL;
}
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
@@ -236,7 +249,7 @@
gpointer data)
{
GbfTreeData *tdata;
- GNOME_Development_TargetSource *source;
+ GbfProjectTargetSource *source;
GdkPixbuf *pixbuf;
gtk_tree_model_get (model, iter, 0, &tdata, -1);
@@ -244,7 +257,7 @@
switch (tdata->type) {
case GBF_TREE_NODE_FILE:
source = tdata->data;
- pixbuf = gdl_icon_for_uri (source->source);
+ pixbuf = gdl_icon_for_uri (source->source_uri);
break;
case GBF_TREE_NODE_FOLDER:
pixbuf = gdl_icon_for_folder ();
@@ -269,14 +282,14 @@
{
GbfTreeData *tdata;
char *str;
- GNOME_Development_TargetSource *source;
+ GbfProjectTargetSource *source;
gtk_tree_model_get (model, iter, 0, &tdata, -1);
switch (tdata->type) {
case GBF_TREE_NODE_FILE:
source = tdata->data;
- str = uri_basename (source->source);
+ str = uri_basename (source->source_uri);
g_object_set (GTK_CELL_RENDERER (cell), "text",
str, NULL);
g_free (str);
@@ -364,20 +377,18 @@
load_data (GbfProjectTree *tree)
{
GbfProjectTreePrivate *priv;
- GNOME_Development_SourceList *source_list;
+ GList *sources, *l;
GtkTreeIter iter;
GtkTreePath *path;
GbfTreeData *node;
char *uri;
- int i;
- CORBA_Environment ev;
-
+
priv = tree->priv;
gtk_tree_store_clear (GTK_TREE_STORE (priv->tree_model));
g_hash_table_foreach_remove (priv->dirs, destroy_tree_node, NULL);
- if (priv->prj == CORBA_OBJECT_NIL) {
+ if (priv->prj == NULL) {
insert_no_project_node (tree);
return;
}
@@ -390,34 +401,26 @@
gtk_tree_store_append (GTK_TREE_STORE (priv->tree_model), &iter, NULL);
gtk_tree_store_set (GTK_TREE_STORE (priv->tree_model), &iter, 0, node, -1);
gbf_tree_data_free (node);
-
- path = gtk_tree_path_new_root ();
+
+ path = gtk_tree_path_new_root ();
g_hash_table_insert (priv->dirs, g_strdup (uri), path);
g_free (uri);
-
+
/* Add all the sources */
- CORBA_exception_init (&ev);
+ sources = GBF_PROJECT_GET_CLASS (priv->prj)->get_all_sources (priv->prj, NULL);
- source_list = GNOME_Development_Project_getAllSources (priv->prj, &ev);
- if (BONOBO_EX (&ev))
- return;
-
- for (i = 0; i < source_list->_length; i++) {
- GNOME_Development_TargetSource *source;
- const CORBA_char *id;
+ for (l = sources; l; l = l->next) {
+ GbfProjectTargetSource *source;
+ const char *id;
GtkTreeIter *parent;
- CORBA_exception_init (&ev);
+ id = l->data;
+ source = GBF_PROJECT_GET_CLASS (priv->prj)->get_source (priv->prj, id, NULL);
- id = source_list->_buffer[i];
- source = GNOME_Development_Project_getSource (priv->prj, id, &ev);
- if (BONOBO_EX (&ev))
- continue;
-
- parent = find_parent (tree, source->source);
+ parent = find_parent (tree, source->source_uri);
node = gbf_tree_data_new (GBF_TREE_NODE_FILE, source);
-
+
gtk_tree_store_append (GTK_TREE_STORE (priv->tree_model),
&iter, parent);
gtk_tree_store_set (GTK_TREE_STORE (priv->tree_model),
@@ -425,39 +428,14 @@
gtk_tree_iter_free (parent);
gbf_tree_data_free (node);
}
- CORBA_free (source_list);
- CORBA_exception_free (&ev);
-
+ g_list_free (sources);
+
gtk_tree_view_expand_row (GTK_TREE_VIEW (priv->tree), path, FALSE);
}
/* ----------------------------------------------------------------------
* Public interface
* ---------------------------------------------------------------------- */
-GType
-gbf_project_tree_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- GTypeInfo info = {
- sizeof (GbfProjectTreeClass),
- NULL, /* base_init. */
- NULL, /* base_finalize. */
- (GClassInitFunc) class_init,
- NULL, /* class_finalize. */
- NULL, /* class_data. */
- sizeof (GbfProjectTree),
- 0, /* n_preallocs. */
- (GInstanceInitFunc) init,
- NULL, /* value_table. */
- };
-
- type = g_type_register_static (GTK_TYPE_VBOX, "GbfProjectTree", &info, 0);
- }
-
- return type;
-}
GtkWidget *
gbf_project_tree_new (void)
@@ -465,15 +443,7 @@
return GTK_WIDGET (g_object_new (GBF_TYPE_PROJECT_TREE, NULL));
}
-GNOME_Development_Project
-gbf_project_tree_get_project (GbfProjectTree *tree)
-{
- g_return_val_if_fail (tree != NULL, NULL);
- g_return_val_if_fail (GBF_IS_PROJECT_TREE (tree), NULL);
-
- return tree->priv->prj;
-}
-
+#if 0
void
gbf_project_tree_set_project (GbfProjectTree *tree,
GNOME_Development_Project prj)
@@ -535,16 +505,6 @@
load_data (tree);
}
-BonoboEventSource *
-gbf_project_tree_get_event_source (GbfProjectTree *tree)
-{
- g_return_val_if_fail (tree != NULL, NULL);
- g_return_val_if_fail (GBF_IS_PROJECT_TREE (tree), NULL);
-
- return tree->priv->event_source;
-}
-
-
static void
event_cb (BonoboListener *listener,
const char *event,
@@ -557,6 +517,7 @@
if (!strcmp (event, "project-changed"))
load_data (tree);
}
+#endif
static void
row_activated_cb (GtkTreeView *tree_view,
@@ -564,31 +525,21 @@
GtkTreeViewColumn *column,
gpointer data)
{
- GbfProjectTree *tree = data;
+ GbfProjectTree *tree = GBF_PROJECT_TREE (data);
GbfTreeData *tdata;
GtkTreeIter iter;
GtkTreeModel *model;
- CORBA_Environment ev;
-
+
model = gtk_tree_view_get_model (tree_view);
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter, 0, &tdata, -1);
if (tdata->type == GBF_TREE_NODE_FILE) {
- BonoboArg *arg;
- GNOME_Development_TargetSource *source =
- (GNOME_Development_TargetSource *) tdata->data;
+ GbfProjectTargetSource *source = tdata->data;
- CORBA_exception_init (&ev);
-
- arg = bonobo_arg_new (BONOBO_ARG_STRING);
- BONOBO_ARG_SET_STRING (arg, CORBA_string_dup (source->source));
- bonobo_event_source_notify_listeners (tree->priv->event_source,
- "file-selected",
- arg, NULL);
- bonobo_arg_release (arg);
-
- CORBA_exception_free (&ev);
+ g_signal_emit (G_OBJECT (tree),
+ tree_signals[FILE_SELECTED], 0,
+ source->source_uri);
}
}
@@ -603,4 +554,3 @@
gtk_tree_store_set (GTK_TREE_STORE (tree->priv->tree_model), &iter,
0, tree->priv->empty_node, -1);
}
-
Index: src/controls/gbf-project-tree.h
===================================================================
RCS file: /cvs/gnome/gnome-build/src/controls/gbf-project-tree.h,v
retrieving revision 1.6
diff -u -r1.6 gbf-project-tree.h
--- src/controls/gbf-project-tree.h 22 Feb 2002 01:41:34 -0000 1.6
+++ src/controls/gbf-project-tree.h 23 Aug 2002 12:59:49 -0000
@@ -25,16 +25,14 @@
#define _GBF_PROJECT_TREE_H_
#include <gtk/gtk.h>
-#include <bonobo/bonobo-event-source.h>
-#include "gnome-build.h"
G_BEGIN_DECLS
#define GBF_TYPE_PROJECT_TREE (gbf_project_tree_get_type ())
#define GBF_PROJECT_TREE(obj) (GTK_CHECK_CAST ((obj), GBF_TYPE_PROJECT_TREE, GbfProjectTree))
#define GBF_PROJECT_TREE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GBF_TYPE_PROJECT_TREE, GbfProjectTreeClass))
-#define GBF_IS_PROJECT_TREE(obj) (GTK_CHECK_TYPE ((obj), GBF_TYPE_PROJECT_TREE))
-#define GBF_IS_PROJECT_TREE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), GBF_TYPE_PROJECT_TREE))
+#define GBF_IS_PROJECT_TREE(obj) (GTK_CHECK_TYPE ((obj), GBF_TYPE_PROJECT_TREE))
+#define GBF_IS_PROJECT_TREE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), GBF_TYPE_PROJECT_TREE))
typedef struct _GbfProjectTree GbfProjectTree;
typedef struct _GbfProjectTreePrivate GbfProjectTreePrivate;
@@ -48,15 +46,12 @@
struct _GbfProjectTreeClass {
GtkVBoxClass parent_class;
-};
-GType gbf_project_tree_get_type (void);
-GtkWidget *gbf_project_tree_new (void);
-GNOME_Development_Project gbf_project_tree_get_project (GbfProjectTree *tree);
-void gbf_project_tree_set_project (GbfProjectTree *tree,
- GNOME_Development_Project prj);
-BonoboEventSource *gbf_project_tree_get_event_source (GbfProjectTree *tree);
+ void (* file_selected) (GbfProjectTree *tree, const char *filename);
+};
+GType gbf_project_tree_get_type (void);
+GtkWidget *gbf_project_tree_new (void);
G_END_DECLS
Index: src/controls/gbf-target-tree.c
===================================================================
RCS file: /cvs/gnome/gnome-build/src/controls/gbf-target-tree.c,v
retrieving revision 1.30
diff -u -r1.30 gbf-target-tree.c
--- src/controls/gbf-target-tree.c 12 Jul 2002 04:38:51 -0000 1.30
+++ src/controls/gbf-target-tree.c 23 Aug 2002 12:59:50 -0000
@@ -21,16 +21,22 @@
* Author: JP Rosevear
*/
-#include <bonobo/bonobo-exception.h>
-#include <bonobo/bonobo-property-bag-client.h>
#include <libgnomevfs/gnome-vfs-types.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include <gtk/gtktreeview.h>
#include <libgnome/gnome-i18n.h>
+#include <libgnome/gnome-macros.h>
#include <gdl/gdl-icons.h>
#include "utils.h"
#include "gbf-tree-data.h"
#include "gbf-target-tree.h"
+#include "gbf-project.h"
+
+enum {
+ FILE_SELECTED,
+ TARGET_SELECTED,
+ LAST_SIGNAL
+};
enum {
PROP_0,
@@ -38,32 +44,26 @@
};
struct _GbfTargetTreePrivate {
- GNOME_Development_Project prj;
-
+ GbfProject *prj;
+
GtkWidget *tree_sw;
GtkWidget *tree;
-
+
GtkTreeModel *tree_model;
GnomeVFSURI *root;
GHashTable *icons;
-
- GNOME_Development_Target *current_target;
- BonoboListener *listener;
-
- BonoboEventSource *event_source;
+ GbfProjectTarget *current_target;
GbfTreeData *empty_node;
};
-static GtkVBoxClass *parent_class = NULL;
+static guint tree_signals [LAST_SIGNAL] = { 0 };
-static void class_init (GbfTargetTreeClass *klass);
-static void init (GbfTargetTree *tree);
static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
static void set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void destroy (GtkObject *object);
+static void dispose (GObject *object);
static void set_pixbuf (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
GtkTreeModel *model, GtkTreeIter *iter,
@@ -72,44 +72,63 @@
GtkTreeModel *model, GtkTreeIter *iter,
gpointer data);
-static void event_cb (BonoboListener *listener,
- const char *event,
- CORBA_any *any,
- CORBA_Environment *ev,
- gpointer user_data);
-
+static void load_data (GbfTargetTree *tree);
+
static void row_activated_cb (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer user_data);
static void insert_no_project_node (GbfTargetTree *tree);
+GNOME_CLASS_BOILERPLATE (GbfTargetTree, gbf_target_tree, GtkVBox, GTK_TYPE_VBOX);
+
static void
-class_init (GbfTargetTreeClass *klass)
+gbf_target_tree_class_init (GbfTargetTreeClass *klass)
{
GObjectClass *g_object_class;
- GtkObjectClass *object_class;
g_object_class = G_OBJECT_CLASS (klass);
- object_class = (GtkObjectClass *) klass;
parent_class = g_type_class_peek_parent (klass);
+ g_object_class->dispose = dispose;
g_object_class->get_property = get_property;
g_object_class->set_property = set_property;
- object_class->destroy = destroy;
-
g_object_class_install_property
(g_object_class, PROP_PROJECT,
g_param_spec_pointer ("project",
_("Project"),
_("Corba Project Object"),
G_PARAM_READWRITE));
+
+ tree_signals [FILE_SELECTED] =
+ g_signal_new ("file_selected",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GbfTargetTreeClass, file_selected),
+ NULL, /* accumulator */
+ NULL, /* accu_data */
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, /* return type */
+ 1,
+ G_TYPE_STRING);
+
+ tree_signals [TARGET_SELECTED] =
+ g_signal_new ("target_selected",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GbfTargetTreeClass, target_selected),
+ NULL, /* accumulator */
+ NULL, /* accu_data */
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, /* return type */
+ 1,
+ G_TYPE_STRING);
}
static void
-init (GbfTargetTree *tree)
+gbf_target_tree_instance_init (GbfTargetTree *tree)
{
GbfTargetTreePrivate *priv;
GtkCellRenderer *renderer;
@@ -165,8 +184,6 @@
(GDestroyNotify)g_free,
(GDestroyNotify)gdk_pixbuf_unref);
- priv->event_source = bonobo_event_source_new ();
-
priv->empty_node = gbf_tree_data_new (GBF_TREE_NODE_STRING,
_("No project loaded."));
insert_no_project_node (tree);
@@ -180,7 +197,7 @@
switch (prop_id) {
case PROP_PROJECT:
- g_value_set_pointer (value, gbf_target_tree_get_project (tree));
+ g_value_set_pointer (value, tree->priv->prj);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -193,10 +210,22 @@
const GValue *value, GParamSpec *pspec)
{
GbfTargetTree *tree = GBF_TARGET_TREE (object);
+ char *dir;
switch (prop_id) {
case PROP_PROJECT:
- gbf_target_tree_set_project (tree, g_value_get_pointer (value));
+ if (tree->priv->root) {
+ gnome_vfs_uri_unref (tree->priv->root);
+ tree->priv->root = NULL;
+ }
+
+ tree->priv->prj = g_value_get_pointer (value);
+ if (tree->priv->prj) {
+ g_object_get (G_OBJECT (tree->priv->prj), "project-dir", &dir, NULL);
+ tree->priv->root = gnome_vfs_uri_new (dir);
+ }
+
+ load_data (tree);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -205,7 +234,7 @@
}
static void
-destroy (GtkObject *object)
+dispose (GObject *object)
{
GbfTargetTree *tree;
GbfTargetTreePrivate *priv;
@@ -214,8 +243,8 @@
priv = tree->priv;
if (priv) {
- if (priv->prj != CORBA_OBJECT_NIL)
- gbf_target_tree_set_project (tree, CORBA_OBJECT_NIL);
+ if (priv->prj != NULL)
+ g_object_unref (priv->prj);
g_hash_table_destroy (priv->icons);
@@ -227,9 +256,6 @@
g_free (priv);
tree->priv = NULL;
}
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
@@ -241,8 +267,8 @@
{
GbfTargetTree *tree;
GbfTreeData *tdata;
- GNOME_Development_Target *target;
- GNOME_Development_TargetSource *source;
+ GbfProjectTarget *target;
+ GbfProjectTargetSource *source;
GdkPixbuf *pixbuf;
tree = GBF_TARGET_TREE (data);
@@ -251,7 +277,7 @@
switch (tdata->type) {
case GBF_TREE_NODE_FILE:
source = tdata->data;
- pixbuf = gdl_icon_for_uri (source->source);
+ pixbuf = gdl_icon_for_uri (source->source_uri);
break;
case GBF_TREE_NODE_FOLDER:
pixbuf = gdl_icon_for_folder ();
@@ -280,15 +306,15 @@
{
GbfTreeData *tdata;
char *str;
- GNOME_Development_Target *target;
- GNOME_Development_TargetSource *source;
+ GbfProjectTarget *target;
+ GbfProjectTargetSource *source;
gtk_tree_model_get (model, iter, 0, &tdata, -1);
switch (tdata->type) {
case GBF_TREE_NODE_FILE:
source = tdata->data;
- str = uri_basename (source->source);
+ str = uri_basename (source->source_uri);
g_object_set (GTK_CELL_RENDERER (cell), "text", str, NULL);
g_free (str);
break;
@@ -317,24 +343,22 @@
load_data (GbfTargetTree *tree)
{
GbfTargetTreePrivate *priv;
- GNOME_Development_TargetList *target_list;
+ GList *targets, *l, *j;
GtkTreeIter iter, child_iter, root_iter;
GtkTreePath *path;
GbfTreeData *node;
char *uri;
- CORBA_Environment ev;
- int i, j;
priv = tree->priv;
gtk_tree_store_clear (GTK_TREE_STORE (priv->tree_model));
- if (priv->prj == CORBA_OBJECT_NIL) {
+ if (priv->prj == NULL) {
insert_no_project_node (tree);
return;
}
- /* Add the highest directory in the tree */
+ /* Add the highest directory in the tree */
uri = gnome_vfs_uri_to_string (priv->root, GNOME_VFS_URI_HIDE_NONE);
node = gbf_tree_data_new (GBF_TREE_NODE_FOLDER, uri);
@@ -345,44 +369,47 @@
gbf_tree_data_free (node);
/* Add all the targets and their sources */
- CORBA_exception_init (&ev);
+ targets = GBF_PROJECT_GET_CLASS (priv->prj)->get_all_targets (priv->prj, NULL);
- target_list = GNOME_Development_Project_getAllTargets (priv->prj, &ev);
- if (BONOBO_EX (&ev))
- return;
-
- for (i = 0; i < target_list->_length; i++) {
- GNOME_Development_Target *target;
- const CORBA_char *id;
-
- CORBA_exception_init (&ev);
-
- id = target_list->_buffer[i];
- target = GNOME_Development_Project_getTarget (priv->prj, id, &ev);
- if (BONOBO_EX (&ev))
+ for (l = targets; l; l = l->next) {
+ GbfProjectTarget *target;
+ const char *id;
+ GError *err = NULL;
+
+ id = l->data;
+ target = GBF_PROJECT_GET_CLASS (priv->prj)->get_target (priv->prj, id, &err);
+ if (err) {
+ g_print ("error retrieving target: %s\n", id);
+ g_error_free (err);
+ err = NULL;
continue;
+ }
node = gbf_tree_data_new (GBF_TREE_NODE_TARGET, target);
-
- /* Add target to the tree */
+
+ /* Add target to the tree */
gtk_tree_store_append (GTK_TREE_STORE (priv->tree_model),
&iter, &root_iter);
gtk_tree_store_set (GTK_TREE_STORE (priv->tree_model), &iter,
0, node, -1);
gbf_tree_data_free (node);
-
+
/* Add sources to the tree */
- for (j = 0; j < target->sources._length; j++) {
- GNOME_Development_TargetSource *source;
- const CORBA_char *id;
-
- id = target->sources._buffer[j];
- source = GNOME_Development_Project_getSource (priv->prj, id, &ev);
- if (BONOBO_EX (&ev))
+ for (j = target->sources; j; j = j->next) {
+ GbfProjectTargetSource *source;
+ const char *id;
+
+ id = j->data;
+ source = GBF_PROJECT_GET_CLASS (priv->prj)->get_source (priv->prj, id, &err);
+ if (err) {
+ g_print ("error retrieving source: %s\n", id);
+ g_error_free (err);
+ err = NULL;
continue;
+ }
node = gbf_tree_data_new (GBF_TREE_NODE_FILE, source);
-
+
gtk_tree_store_append (GTK_TREE_STORE (priv->tree_model),
&child_iter, &iter);
gtk_tree_store_set (GTK_TREE_STORE (priv->tree_model), &child_iter,
@@ -390,7 +417,7 @@
gbf_tree_data_free (node);
}
}
- CORBA_free (target_list);
+ g_list_free (targets);
/* Expand first levels. */
path = gtk_tree_path_new_root ();
@@ -408,111 +435,7 @@
return GTK_WIDGET (g_object_new (GBF_TYPE_TARGET_TREE, NULL));
}
-GType
-gbf_target_tree_get_type (void)
-{
- static GType type = 0;
-
- if (!type) {
- GTypeInfo info = {
- sizeof (GbfTargetTreeClass),
- NULL, /* base_init. */
- NULL, /* base_finalize. */
- (GClassInitFunc) class_init,
- NULL, /* class_finalize. */
- NULL, /* class_data. */
- sizeof (GbfTargetTree),
- 0, /* n_preallocs. */
- (GInstanceInitFunc) init,
- NULL, /* value_table. */
- };
-
- type = g_type_register_static (GTK_TYPE_VBOX, "GbfTargetTree", &info, 0);
- }
-
- return type;
-}
-
-GNOME_Development_Project
-gbf_target_tree_get_project (GbfTargetTree *tree)
-{
- g_return_val_if_fail (tree != NULL, NULL);
- g_return_val_if_fail (GBF_IS_TARGET_TREE (tree), NULL);
-
- return tree->priv->prj;
-}
-
-void
-gbf_target_tree_set_project (GbfTargetTree *tree,
- GNOME_Development_Project prj)
-{
- GbfTargetTreePrivate *priv;
- Bonobo_EventSource source;
- CORBA_Environment ev;
-
- g_return_if_fail (tree != NULL);
- g_return_if_fail (GBF_IS_TARGET_TREE (tree));
-
- priv = tree->priv;
-
- CORBA_exception_init (&ev);
-
- if (priv->prj) {
- source = Bonobo_Unknown_queryInterface (priv->prj, "IDL:Bonobo/EventSource:1.0", &ev);
- Bonobo_EventSource_removeListener (source, BONOBO_OBJREF (priv->listener), &ev);
- bonobo_object_release_unref (source, &ev);
- bonobo_object_release_unref (priv->prj, &ev);
- CORBA_exception_free (&ev);
- }
-
- priv->prj = bonobo_object_dup_ref (prj, &ev);
-
- if (prj != CORBA_OBJECT_NIL) {
- Bonobo_PropertyBag pb;
- char *dir;
-
- /* Find the project dir */
- if (priv->root)
- gnome_vfs_uri_unref (priv->root);
- priv->root = NULL;
-
- pb = Bonobo_Unknown_queryInterface (prj, "IDL:Bonobo/PropertyBag:1.0", &ev);
- dir = bonobo_pbclient_get_string (pb, "project-dir", NULL);
- bonobo_object_release_unref (pb, &ev);
- CORBA_exception_free (&ev);
-
- priv->root = gnome_vfs_uri_new (dir);
-
- /* Listen for signals */
- priv->listener = bonobo_listener_new (NULL, NULL);
- g_signal_connect (priv->listener, "event_notify",
- G_CALLBACK (event_cb), tree);
-
- source = Bonobo_Unknown_queryInterface (prj, "IDL:Bonobo/EventSource:1.0", &ev);
-
- if (BONOBO_EX (&ev))
- g_error ("couldn't get event source for project");
- else
- Bonobo_EventSource_addListener (source, BONOBO_OBJREF (priv->listener), &ev);
-
- bonobo_object_unref (priv->listener);
- bonobo_object_release_unref (source, &ev);
- }
-
- CORBA_exception_free (&ev);
-
- load_data (tree);
-}
-
-GNOME_Development_Target *
-gbf_target_tree_get_current_target (GbfTargetTree *tree)
-{
- g_return_val_if_fail (tree != NULL, NULL);
- g_return_val_if_fail (GBF_IS_TARGET_TREE (tree), NULL);
-
- return tree->priv->current_target;
-}
-
+#if 0
void
gbf_target_tree_set_current_target (GbfTargetTree *tree,
GNOME_Development_Target *target)
@@ -540,13 +463,9 @@
}
#endif
}
+#endif
-BonoboEventSource *
-gbf_target_tree_get_event_source (GbfTargetTree *tree)
-{
- return tree->priv->event_source;
-}
-
+#if 0
static void
event_cb (BonoboListener *listener,
const char *event,
@@ -562,6 +481,7 @@
if (!strcmp (event, "project-changed"))
load_data (tree);
}
+#endif
static void
row_activated_cb (GtkTreeView *tree_view,
@@ -569,46 +489,34 @@
GtkTreeViewColumn *column,
gpointer data)
{
- GbfTargetTree *tree;
- GbfTargetTreePrivate *priv;
+ GbfTargetTree *tree = GBF_TARGET_TREE (data);
GbfTreeData *tdata;
GtkTreeIter iter;
GtkTreeModel *model;
- GNOME_Development_TargetSource *source;
- BonoboArg *arg;
- CORBA_Environment ev;
-
- tree = GBF_TARGET_TREE (data);
- priv = tree->priv;
-
+ GbfProjectTargetSource *source;
+ GbfProjectTarget *target;
+
model = gtk_tree_view_get_model (tree_view);
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter, 0, &tdata, -1);
- CORBA_exception_init (&ev);
-
switch (tdata->type) {
case GBF_TREE_NODE_FILE:
source = tdata->data;
- arg = bonobo_arg_new (BONOBO_ARG_STRING);
- BONOBO_ARG_SET_STRING (arg, CORBA_string_dup (source->source));
- bonobo_event_source_notify_listeners (tree->priv->event_source,
- "file-selected",
- arg, NULL);
- bonobo_arg_release (arg);
+
+ g_signal_emit (G_OBJECT (tree),
+ tree_signals[FILE_SELECTED], 0,
+ source->source_uri);
break;
case GBF_TREE_NODE_TARGET:
- arg = bonobo_arg_new_from (TC_GNOME_Development_Target, tdata->data);
- gbf_target_tree_set_current_target (tree, tdata->data);
- bonobo_event_source_notify_listeners (tree->priv->event_source,
- "target-selected",
- arg, NULL);
- bonobo_arg_release (arg);
+ target = tdata->data;
+
+ g_signal_emit (G_OBJECT (tree),
+ tree_signals[TARGET_SELECTED], 0,
+ target->id);
break;
default:
}
-
- CORBA_exception_free (&ev);
}
static void
Index: src/controls/gbf-target-tree.h
===================================================================
RCS file: /cvs/gnome/gnome-build/src/controls/gbf-target-tree.h,v
retrieving revision 1.8
diff -u -r1.8 gbf-target-tree.h
--- src/controls/gbf-target-tree.h 23 Feb 2002 05:30:38 -0000 1.8
+++ src/controls/gbf-target-tree.h 23 Aug 2002 12:59:50 -0000
@@ -24,9 +24,7 @@
#ifndef _GBF_TARGET_TREE_H_
#define _GBF_TARGET_TREE_H_
-#include <gnome.h>
-#include <bonobo/bonobo-event-source.h>
-#include "gnome-build.h"
+#include <gtk/gtk.h>
G_BEGIN_DECLS
@@ -48,17 +46,13 @@
struct _GbfTargetTreeClass {
GtkVBoxClass parent_class;
+
+ void (* file_selected) (GbfTargetTree *tree, const char *filename);
+ void (* target_selected) (GbfTargetTree *tree, const char *target_id);
};
-GType gbf_target_tree_get_type (void);
-GtkWidget *gbf_target_tree_new (void);
-GNOME_Development_Project gbf_target_tree_get_project (GbfTargetTree *tree);
-void gbf_target_tree_set_project (GbfTargetTree *tree,
- GNOME_Development_Project project);
-GNOME_Development_Target *gbf_target_tree_get_current_target (GbfTargetTree *tree);
-void gbf_target_tree_set_current_target (GbfTargetTree *tree,
- GNOME_Development_Target *target);
-BonoboEventSource *gbf_target_tree_get_event_source (GbfTargetTree *tree);
+GType gbf_target_tree_get_type (void);
+GtkWidget *gbf_target_tree_new (void);
G_END_DECLS
Index: src/controls/test-controls.c
===================================================================
RCS file: /cvs/gnome/gnome-build/src/controls/test-controls.c,v
retrieving revision 1.4
diff -u -r1.4 test-controls.c
--- src/controls/test-controls.c 12 Jul 2002 04:38:51 -0000 1.4
+++ src/controls/test-controls.c 23 Aug 2002 12:59:50 -0000
@@ -1,16 +1,20 @@
#include <config.h>
#include <gnome.h>
-#include <bonobo.h>
+#include <string.h>
+#include <libbonoboui.h>
#include <libgnomevfs/gnome-vfs-uri.h>
-#include "gnome-build.h"
+#include "gbf-backend.h"
+#include "gbf-project-tree.h"
+#include "gbf-target-tree.h"
+#include "gbf-build-info.h"
#define TEST_CONTROLS_UI_XML "test-controls.xml"
static GtkWidget *app;
-static GNOME_Development_Project proj = CORBA_OBJECT_NIL;
-static Bonobo_Control project_ctrl;
-static Bonobo_Control target_ctrl;
-static Bonobo_Control info_ctrl;
+static GbfProject *proj = NULL;
+static GtkWidget *project_tree;
+static GtkWidget *target_tree;
+static GtkWidget *build_info;
static void open_cb (GtkWidget *widget,
gpointer user_data,
@@ -22,65 +26,46 @@
char *cname);
static BonoboUIVerb verbs[] = {
- BONOBO_UI_UNSAFE_VERB ("FileOpen", open_cb),
- BONOBO_UI_UNSAFE_VERB ("FileExit", exit_cb),
- BONOBO_UI_VERB_END
+ BONOBO_UI_UNSAFE_VERB ("FileOpen", open_cb),
+ BONOBO_UI_UNSAFE_VERB ("FileExit", exit_cb),
+ BONOBO_UI_VERB_END
};
-static GNOME_Development_Project
-activate_id (const char *id)
-{
- CORBA_Object object = CORBA_OBJECT_NIL;
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
-
- object = bonobo_activation_activate_from_id (id, Bonobo_ACTIVATION_FLAG_PRIVATE, NULL, &ev);
-
- if (BONOBO_EX (&ev))
- g_error ("Unable to activate object");
-
- CORBA_exception_free (&ev);
-
- return (GNOME_Development_Project) object;
-}
-
static void
open_cb (GtkWidget *widget,
gpointer user_data,
char *cname)
{
- GtkWidget *file_sel;
-
- file_sel = gtk_file_selection_new (_("Open Project"));
- g_signal_connect (GTK_FILE_SELECTION (file_sel)->ok_button, "clicked",
- G_CALLBACK (open_project), file_sel);
+ GtkWidget *file_sel;
-
- g_signal_connect_swapped (GTK_FILE_SELECTION (file_sel)->ok_button,
- "clicked", G_CALLBACK (gtk_widget_destroy),
- file_sel);
- g_signal_connect_swapped (GTK_FILE_SELECTION (file_sel)->cancel_button,
- "clicked", G_CALLBACK (gtk_widget_destroy),
- file_sel);
-
- gtk_widget_show (file_sel);
+ file_sel = gtk_file_selection_new (_("Open Project"));
+
+ g_signal_connect (GTK_FILE_SELECTION (file_sel)->ok_button,
+ "clicked",
+ G_CALLBACK (open_project),
+ file_sel);
+
+ g_signal_connect_swapped (GTK_FILE_SELECTION (file_sel)->ok_button,
+ "clicked", G_CALLBACK (gtk_widget_destroy),
+ file_sel);
+ g_signal_connect_swapped (GTK_FILE_SELECTION (file_sel)->cancel_button,
+ "clicked", G_CALLBACK (gtk_widget_destroy),
+ file_sel);
+
+ gtk_widget_show (file_sel);
}
static void
open_project (GtkWidget *widget,
- gpointer user_data)
+ gpointer user_data)
{
- Bonobo_ServerInfoList *result;
GtkFileSelection *file_sel;
const gchar *filename;
GnomeVFSURI *vfs_uri;
gchar *dirname;
- Bonobo_PropertyBag pb;
- BonoboArg *arg;
-
- CORBA_Environment ev;
-
+ GSList *l;
+ GbfBackend *backend = NULL;
+
file_sel = GTK_FILE_SELECTION (user_data);
filename = gtk_file_selection_get_filename (file_sel);
@@ -91,49 +76,37 @@
dirname = gnome_vfs_uri_extract_dirname (vfs_uri);
gnome_vfs_uri_unref (vfs_uri);
- if (proj != CORBA_OBJECT_NIL)
- bonobo_object_release_unref (proj, &ev);
+ if (proj != NULL)
+ g_object_unref (proj);
- CORBA_exception_init (&ev);
+ g_print ("initializing gbf backend...\n");
+ gbf_backend_init ();
- /* Get a project */
- result = bonobo_activation_query ("repo_ids.has ('IDL:GNOME/Development/Build:1.0')", NULL, &ev);
- g_assert (!BONOBO_EX (&ev));
+ for (l = gbf_backend_get_backends (); l; l = l->next) {
+ backend = l->data;
+ if (!strcmp (backend->id, "gbf-am:GbfAmProject"))
+ break;
+ backend = NULL;
+ }
- proj = activate_id (result->_buffer[0].iid);
- g_assert (proj != CORBA_OBJECT_NIL);
+ if (!backend) {
+ g_print ("no automake/autoconf backend available\n");
+ return;
+ }
- CORBA_free (result);
-
- GNOME_Development_Project_load (proj, dirname, &ev);
- if (BONOBO_EX (&ev))
- g_error ("Unable to load project");
+ g_print ("creating new gbf-am project\n");
+ proj = gbf_backend_new_project (backend->id);
+ if (!proj) {
+ g_print ("project creation failed\n");
+ return;
+ }
- arg = bonobo_arg_new (TC_GNOME_Development_Project);
- BONOBO_ARG_SET_GENERAL (arg, proj, TC_GNOME_Development_Project, GNOME_Development_Project, NULL);
-
- /* Tell GbfProjectTree to display the project. */
- pb = Bonobo_Control_getProperties (project_ctrl, &ev);
- g_assert (!BONOBO_EX (&ev));
-
- bonobo_pbclient_set_value (pb, "project", arg, &ev);
- g_assert (!BONOBO_EX (&ev));
- bonobo_object_release_unref (pb, &ev);
- g_assert (!BONOBO_EX (&ev));
-
- /* Tell GbfTargetTree to display the project. */
- pb = Bonobo_Control_getProperties (target_ctrl, &ev);
- g_assert (!BONOBO_EX (&ev));
-
- bonobo_pbclient_set_value (pb, "project", arg, &ev);
- g_assert (!BONOBO_EX (&ev));
- bonobo_object_release_unref (pb, &ev);
- g_assert (!BONOBO_EX (&ev));
+ g_print ("loading project %s\n\n", dirname);
+ GBF_PROJECT_GET_CLASS (proj)->load (proj, dirname, NULL);
- BONOBO_ARG_SET_GENERAL (arg, CORBA_OBJECT_NIL, TC_GNOME_Development_Project, GNOME_Development_Project, NULL);
- bonobo_arg_release (arg);
-
- CORBA_exception_free (&ev);
+ g_object_set (G_OBJECT (project_tree), "project", proj, NULL);
+ /*g_object_set (G_OBJECT (target_tree), "project", proj, NULL);
+ g_object_set (G_OBJECT (build_info), "project", proj, NULL);*/
}
static void
@@ -146,6 +119,7 @@
bonobo_main_quit ();
}
+#if 0
static void
event_cb (BonoboListener *listener,
const char *event,
@@ -223,6 +197,7 @@
CORBA_exception_free (&ev);
}
+#endif
static void
window_destroyed (GtkWidget *window,
@@ -244,7 +219,7 @@
BonoboWindow *win;
BonoboUIContainer *ui_container;
BonoboUIComponent *ui_component;
- GtkWidget *project_tree, *target_tree, *build_info, *notebook, *paned;
+ GtkWidget *notebook, *paned;
win = BONOBO_WINDOW (bonobo_window_new (GETTEXT_PACKAGE, _("Test Controls")));
@@ -280,22 +255,13 @@
paned = gtk_vpaned_new ();
/* Create GbfProjectTree control. */
- project_tree = bonobo_widget_new_control ("OAFIID:GNOME_Development_ProjectTree",
- BONOBO_OBJREF (ui_container));
- project_ctrl = bonobo_widget_get_objref (BONOBO_WIDGET (project_tree));
- add_event_listener (project_ctrl);
-
+ project_tree = gbf_project_tree_new ();
+
/* Create GbfTargetTree control. */
- target_tree = bonobo_widget_new_control ("OAFIID:GNOME_Development_TargetTree",
- BONOBO_OBJREF (ui_container));
- target_ctrl = bonobo_widget_get_objref (BONOBO_WIDGET (target_tree));
- add_event_listener (target_ctrl);
+ target_tree = gbf_target_tree_new ();
/* Create GbfBuildInfo control. */
- build_info = bonobo_widget_new_control ("OAFIID:GNOME_Development_BuildInfo",
- BONOBO_OBJREF (ui_container));
- info_ctrl = bonobo_widget_get_objref (BONOBO_WIDGET (build_info));
- add_event_listener (info_ctrl);
+ build_info = gbf_build_info_new ();
/* Add everything to the notebook and display it. */
gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
@@ -334,9 +300,9 @@
bonobo_main ();
if (proj)
- bonobo_object_release_unref (proj, NULL);
-
+ g_object_unref (proj);
+
bonobo_ui_debug_shutdown ();
-
+
return 0;
}
Index: src/lib/Makefile.am
===================================================================
RCS file: /cvs/gnome/gnome-build/src/lib/Makefile.am,v
retrieving revision 1.9
diff -u -r1.9 Makefile.am
--- src/lib/Makefile.am 12 Jul 2002 04:38:52 -0000 1.9
+++ src/lib/Makefile.am 23 Aug 2002 12:59:50 -0000
@@ -1,45 +1,37 @@
INCLUDES = \
- -DGNOMELOCALEDIR=\""$(datadir)/locale"\"\
- -DG_DISABLE_DEPRECATED \
- -DGTK_DISABLE_DEPRECATED \
- $(WARN_CFLAGS) \
- $(GBF_LIB_CFLAGS)
-
-CORBA_GENERATED_HEADER_FILES = gnome-build.h
-
-CORBA_GENERATED = \
- $(CORBA_GENERATED_HEADER_FILES) \
- gnome-build-common.c \
- gnome-build-stubs.c \
- gnome-build-skels.c
-
-idl_dir = $(top_srcdir)/idl
-
-IDL_FLAGS = -I $(idl_dir) -I $(datadir)/idl \
- -I $(LIBBONOBO_IDL_DIR) \
- -I $(BONOBO_ACTIVATION_IDL_DIR)
-
-$(CORBA_GENERATED): $(idl_dir)/gnome-build.idl $(idl_dir)/gbf-types.idl $(idl_dir)/gbf-project.idl
- $(ORBIT_IDL) $(IDL_FLAGS) $(idl_dir)/gnome-build.idl
-
-BUILT_SOURCES = \
- $(CORBA_GENERATED)
-
-CLEANFILES = $(CORBA_GENERATED)
+ -DGNOMELOCALEDIR=\""$(datadir)/locale"\"\
+ -DPREFIX=\""$(prefix)"\" \
+ -DG_DISABLE_DEPRECATED \
+ -DGTK_DISABLE_DEPRECATED \
+ $(WARN_CFLAGS) \
+ $(GBF_CONTROL_CFLAGS)
lib_LTLIBRARIES = \
libgbf-1.la
-libgbf_1_la_SOURCES = \
- $(CORBA_GENERATED)
+libgbf_1_la_SOURCES = \
+ glue-factory.h \
+ glue-factory.c \
+ glue-plugin.h \
+ glue-plugin.c \
+ gbf-project.h \
+ gbf-project.c \
+ gbf-backend.h \
+ gbf-backend.c
libgbf_1_la_LIBADD = \
- $(GBF_LIB_LIBS)
+ $(GBF_CONTROL_LIBS)
libgbfincludedir = $(includedir)/gnome-build-1.0/gbf
-
libgbfinclude_HEADERS = \
- $(CORBA_GENERATED_HEADER_FILES)
+ gbf-project.h \
+ gbf-backend.h
+noinst_PROGRAMS = test
+test_SOURCES = \
+ test.c
+test_LDADD = \
+ libgbf-1.la \
+ $(GBF_CONTROL_LIBS)
/* gbf-backend.c
*
* Copyright (C) 2002 Jeroen Zwartepoorte
*
* 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 Library 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.
*/
#include <config.h>
#include <sys/types.h>
#include <dirent.h>
#include <string.h>
#include <libxml/tree.h>
#include "glue-factory.h"
#include "gbf-backend.h"
#define BACKEND_DIR PREFIX "/lib/gnome-build/backends"
static GList *plugin_dirs = NULL;
static GSList *available_backends = NULL;
static GHashTable *backends_by_name = NULL;
static GlueFactory *glue_factory = NULL;
static void
destroy_backend (GbfBackend *backend)
{
if (backend->id)
g_free (backend->id);
if (backend->name)
g_free (backend->name);
g_free (backend);
}
static gboolean
str_has_suffix (const char *haystack,
const char *needle)
{
const char *h, *n;
if (needle == NULL)
return TRUE;
if (haystack == NULL)
return needle[0] == '\0';
/* Eat one character at a time. */
h = haystack + strlen(haystack);
n = needle + strlen(needle);
do {
if (n == needle) {
return TRUE;
}
if (h == haystack) {
return FALSE;
}
} while (*--h == *--n);
return FALSE;
}
static char *
get_attr (GHashTable *attrs,
const char *name,
GList *lang_list)
{
#if 0
GList *l;
char *ret;
for (l = lang_list; l != NULL; l = l->next) {
char *lang_attr = g_strdup_printf ("%s-%s",
name,
(char*)l->data);
ret = g_hash_table_lookup (attrs, lang_attr);
g_free (lang_attr);
if (ret)
return ret;
}
#endif
return g_hash_table_lookup (attrs, name);
}
static GHashTable *
read_backend_attributes (xmlNodePtr backend)
{
xmlNodePtr attr;
GHashTable *attributes;
attributes = g_hash_table_new (g_str_hash, g_str_equal);
for (attr = backend->children; attr != NULL; attr = attr->next) {
char *type = xmlGetProp (attr, "type");
if (type) {
char *name;
char *value;
if (strcmp (type, "string")) {
g_warning ("gnome-build only supports string-type oaf attributes");
return NULL;
}
name = xmlGetProp (attr, "name");
value = xmlGetProp (attr, "value");
if (name && value) {
g_hash_table_insert (attributes, name, value);
} else {
g_warning ("Missing name or value in attribute");
}
}
}
return attributes;
}
static GbfBackend *
backend_from_attributes (xmlNodePtr plugin,
GHashTable *attrs)
{
static GList *langs = NULL;
GbfBackend *backend = g_new0 (GbfBackend, 1);
gboolean success = TRUE;
char *str;
#if 0
if (!langs)
langs = anjuta_get_lang_list ();
#endif
str = xmlGetProp (plugin, "location");
if (str) {
backend->id = g_strdup (str);
} else {
g_warning ("Couldn't find 'location'");
success = FALSE;
}
str = get_attr (attrs, "name", langs);
if (str) {
backend->name = g_strdup (str);
} else {
g_warning ("couldn't find 'name' attribute.");
success = FALSE;
}
str = get_attr (attrs, "description", langs);
if (str) {
backend->description = g_strdup (str);
} else {
g_warning ("Couldn't find 'description' attribute.");
success = FALSE;
}
if (!success) {
destroy_backend (backend);
backend = NULL;
}
return backend;
}
static void
load_backend (xmlNodePtr node)
{
GHashTable *attrs;
GbfBackend *backend;
attrs = read_backend_attributes (node);
backend = backend_from_attributes (node, attrs);
if (backend) {
if (g_hash_table_lookup (backends_by_name, backend->id)) {
destroy_backend (backend);
} else {
available_backends = g_slist_prepend (available_backends,
backend);
g_hash_table_insert (backends_by_name, backend->id, backend);
}
}
g_hash_table_destroy (attrs);
}
static void
load_backend_file (const char *path)
{
xmlDocPtr doc;
xmlNodePtr root;
xmlNodePtr backend;
doc = xmlParseFile (path);
if ((root = xmlDocGetRootElement (doc)) == NULL) {
g_warning ("%s is not a valid backend description file", path);
xmlFreeDoc (doc);
return;
}
for (backend = root->children; backend != NULL; backend = backend->next) {
if (xmlGetProp (backend, "location")) {
load_backend (backend);
}
}
}
static void
load_backends_from_directory (const char *dirname)
{
DIR *dir;
struct dirent *entry;
dir = opendir (dirname);
if (!dir)
return;
for (entry = readdir (dir); entry != NULL; entry = readdir (dir)) {
if (str_has_suffix (entry->d_name, ".server")) {
char *pathname;
pathname = g_strdup_printf ("%s/%s",
dirname,
entry->d_name);
load_backend_file (pathname);
g_free (pathname);
}
}
}
static void
load_available_backends (void)
{
GList *l;
backends_by_name = g_hash_table_new (g_str_hash, g_str_equal);
for (l = plugin_dirs; l != NULL; l = l->next) {
load_backends_from_directory ((char*)l->data);
}
}
void
gbf_backend_init (void)
{
static gboolean initialized = FALSE;
const char *gnome2_path;
char **pathv;
char **p;
if (initialized)
return;
initialized = TRUE;
glue_factory = glue_factory_new ();
gnome2_path = g_getenv ("GNOME2_PATH");
if (gnome2_path) {
pathv = g_strsplit (gnome2_path, ":", 1);
for (p = pathv; *p != NULL; p++) {
char *path = g_strdup (*p);
plugin_dirs = g_list_prepend (plugin_dirs, path);
glue_factory_add_path (glue_factory, path);
}
g_strfreev (pathv);
}
plugin_dirs = g_list_prepend (NULL, BACKEND_DIR);
glue_factory_add_path (glue_factory, BACKEND_DIR);
plugin_dirs = g_list_reverse (plugin_dirs);
load_available_backends ();
}
GSList *
gbf_backend_get_backends (void)
{
return available_backends;
}
GbfProject *
gbf_backend_new_project (const char *id)
{
static GHashTable *types = NULL;
GType type;
GbfProject *project;
if (!types) {
types = g_hash_table_new (g_str_hash, g_str_equal);
}
type = GPOINTER_TO_UINT (g_hash_table_lookup (types, id));
if (!type) {
char **pieces;
pieces = g_strsplit (id, ":", -1);
type = glue_factory_get_object_type (glue_factory,
pieces[0],
pieces[1]);
g_hash_table_insert (types,
g_strdup (id),
GUINT_TO_POINTER (type));
g_strfreev (pieces);
}
if (type == G_TYPE_INVALID) {
g_warning ("Invalid type\n");
project = NULL;
} else {
project = GBF_PROJECT (g_object_new (type, NULL));
}
return project;
}
/* gbf-backend.h
*
* Copyright (C) 2002 Jeroen Zwartepoorte
*
* 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 Library 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.
*/
#ifndef _GBF_BACKEND_H_
#define _GBF_BACKEND_H_
#include "gbf-project.h"
G_BEGIN_DECLS
typedef struct _GbfBackend GbfBackend;
struct _GbfBackend {
char *id;
char *name;
char *description;
};
void gbf_backend_init (void);
GSList *gbf_backend_get_backends (void);
GbfProject *gbf_backend_new_project (const char *id);
G_END_DECLS
#endif /* _GBF_BACKEND_H_ */
/* gbf-project.c
*
* Copyright (C) 2002 Jeroen Zwartepoorte
*
* 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 Library 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.
*/
#include <config.h>
#include <libgnome/gnome-macros.h>
#include "gbf-project.h"
GNOME_CLASS_BOILERPLATE (GbfProject, gbf_project, GObject, G_TYPE_OBJECT);
static void
gbf_project_class_init (GbfProjectClass *klass)
{
parent_class = g_type_class_peek_parent (klass);
g_signal_new ("build_started",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GbfProjectClass, build_started),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_signal_new ("build_msg",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GbfProjectClass, build_msg),
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1,
G_TYPE_INT);
g_signal_new ("build_finished",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GbfProjectClass, build_finished),
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1,
G_TYPE_BOOLEAN);
}
static void
gbf_project_instance_init (GbfProject *project)
{
}
GQuark
gbf_project_error_quark (void)
{
static GQuark quark = 0;
if (quark == 0)
quark = g_quark_from_static_string ("gbf-project-quark");
return quark;
}
/* gbf-project.h
*
* Copyright (C) 2002 Jeroen Zwartepoorte
*
* 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 Library 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.
*/
#ifndef _GBF_PROJECT_H_
#define _GBF_PROJECT_H_
#include <glib-object.h>
#include <gtk/gtkwidget.h>
G_BEGIN_DECLS
#define GBF_TYPE_PROJECT (gbf_project_get_type ())
#define GBF_PROJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GBF_TYPE_PROJECT, GbfProject))
#define GBF_PROJECT_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((klass), GBF_TYPE_PROJECT, GbfProjectClass))
#define GBF_IS_PROJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GBF_TYPE_PROJECT))
#define GBF_IS_PROJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GBF_TYPE_PROJECT))
#define GBF_PROJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GBF_TYPE_PROJECT, GbfProjectClass))
#define GBF_PROJECT_ERROR (gbf_project_error_quark ())
typedef struct _GbfProject GbfProject;
typedef struct _GbfProjectClass GbfProjectClass;
typedef struct _GbfProjectGroup GbfProjectGroup;
typedef struct _GbfProjectTarget GbfProjectTarget;
typedef struct _GbfProjectTargetSource GbfProjectTargetSource;
typedef enum _GbfProjectError GbfProjectError;
typedef enum _GbfBuildType GbfBuildType;
typedef enum _GbfBuildMessage GbfBuildMessage;
struct _GbfProject {
GObject parent;
};
struct _GbfProjectClass {
GObjectClass parent_class;
/* Signals */
void (*build_started) (GbfProject *project);
void (*build_msg) (GbfProject *project, GbfBuildMessage type);
void (*build_finished) (GbfProject *project, gboolean success);
/* Virtual Table */
/* Project. */
void (*load) (GbfProject *project,
const char *path,
GError **error);
void (*build) (GbfProject *project,
GbfBuildType type,
GError **error);
/* Groups. */
const char * (*add_group) (GbfProject *project,
const char *parent_id,
const char *name,
GError **error);
void (*remove_group) (GbfProject *project,
const char *id,
GError **error);
GbfProjectGroup * (*get_group) (GbfProject *project,
const char *id,
GError **error);
GtkWidget * (*configure_group) (GbfProject *project,
const char *id,
GError **error);
GtkWidget * (*configure_new_group) (GbfProject *project,
GError **error);
/* Targets. */
const char * (*add_target) (GbfProject *project,
const char *group_id,
const char *name,
const char *type,
GError **error);
void (*remove_target) (GbfProject *project,
const char *id,
GError **error);
GbfProjectTarget * (*get_target) (GbfProject *project,
const char *id,
GError **error);
GList * (*get_all_targets) (GbfProject *project,
GError **error);
GtkWidget * (*configure_target) (GbfProject *project,
const char *id,
GError **error);
GtkWidget * (*configure_new_target) (GbfProject *project,
GError **error);
/* Sources. */
const char * (*add_source) (GbfProject *project,
const char *target_id,
const char *uri,
GError **error);
void (*remove_source) (GbfProject *project,
const char *id,
GError **error);
GbfProjectTargetSource * (*get_source) (GbfProject *project,
const char *id,
GError **error);
GList * (*get_all_sources) (GbfProject *project,
GError **error);
GtkWidget * (*configure_source) (GbfProject *project,
const char *id,
GError **error);
GtkWidget * (*configure_new_source) (GbfProject *project,
GError **error);
/* Types. */
const char * (*name_for_type) (GbfProject *project,
const char *type);
GdkPixbuf * (*icon_for_type) (GbfProject *project,
const char *type);
};
struct _GbfProjectGroup {
char *id;
char *parent_id;
char *name;
GList *groups;
GList *targets;
};
struct _GbfProjectTarget {
char *id;
char *group_id;
char *name;
char *type;
GList *sources;
};
struct _GbfProjectTargetSource {
char *id;
char *target_id;
char *source_uri;
};
enum _GbfProjectError {
GBF_PROJECT_ERROR_DOESNT_EXIST,
GBF_PROJECT_ERROR_PROJECT_MALFORMED
};
enum _GbfBuildType {
GBF_BUILD_PREPARE,
GBF_BUILD_CONFIGURE,
GBF_BUILD_CLEAN,
GBF_BUILD_ALL,
GBF_BUILD_CURRENT,
GBF_BUILD_INSTALL
};
enum _GbfBuildMessage {
GBF_BUILD_DATA,
GBF_BUILD_ERROR,
GBF_BUILD_WARNING
};
GQuark gbf_project_error_quark (void);
GType gbf_project_get_type (void);
#define GBF_BACKEND_BOILERPLATE(class_name, prefix) \
GType \
prefix##_get_type (GluePlugin *plugin) \
{ \
static GType type = 0; \
if (!type) { \
static const GTypeInfo type_info = { \
sizeof (class_name##Class), \
NULL, \
NULL, \
(GClassInitFunc)prefix##_class_init, \
NULL, \
NULL, \
sizeof (class_name), \
0, \
(GInstanceInitFunc)prefix##_instance_init \
}; \
type = g_type_module_register_type (G_TYPE_MODULE (plugin), \
GBF_TYPE_PROJECT, \
#class_name, \
&type_info, 0); \
} \
return type; \
}
#define GBF_SIMPLE_BACKEND(class_name, prefix) \
G_MODULE_EXPORT void glue_register_components (GluePlugin *plugin); \
G_MODULE_EXPORT GType glue_get_component_type (GluePlugin *plugin, const char *name); \
G_MODULE_EXPORT void \
glue_register_components (GluePlugin *plugin) \
{ \
prefix##_get_type (plugin); \
} \
G_MODULE_EXPORT GType \
glue_get_component_type (GluePlugin *plugin, const char *name) \
{ \
if (!strcmp (name, #class_name)) { \
return prefix##_get_type (plugin); \
} else { \
return G_TYPE_INVALID; \
} \
}
G_END_DECLS
#endif /* _GBF_PROJECT_H_ */
#include <string.h>
#include <gmodule.h>
#include "glue-factory.h"
#include "glue-plugin.h"
static void glue_factory_init (GlueFactory *factory);
static void glue_factory_class_init (GlueFactoryClass *class);
typedef GType (*GluePluginGetTypeFunc) (GluePlugin *plugin, const char *name);
typedef struct
{
GluePlugin *plugin;
GluePluginGetTypeFunc get_type_func;
const gchar *name;
} LoadedPlugin;
typedef struct
{
const gchar *path;
GHashTable *loaded_plugins;
} PathEntry;
struct _GlueFactory
{
GObject parent;
GList *paths;
};
struct _GlueFactoryClass
{
GObjectClass parent_class;
};
GType
glue_factory_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo type_info =
{
sizeof (GlueFactoryClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) glue_factory_class_init,
(GClassFinalizeFunc) NULL,
NULL,
sizeof (GlueFactory),
0, /* n_preallocs */
(GInstanceInitFunc) glue_factory_init,
};
type = g_type_register_static (G_TYPE_OBJECT,
"GlueFactory",
&type_info, 0);
}
return type;
}
static void
glue_factory_class_init (GlueFactoryClass *class)
{
}
static void
glue_factory_init (GlueFactory *factory)
{
}
GlueFactory *
glue_factory_new (void)
{
GlueFactory *factory;
factory = g_object_new (glue_factory_get_type (), NULL);
return factory;
}
gboolean
glue_factory_add_path (GlueFactory *factory, const gchar *path)
{
GList *p;
PathEntry *entry;
if (!g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
return FALSE;
/* Check if the path has been added */
p = factory->paths;
while (p)
{
PathEntry *entry = p->data;
/* If it's already added we return TRUE */
if (strcmp (path, entry->path) == 0)
return TRUE;
p = p->next;
}
entry = g_new (PathEntry, 1);
entry->path = g_strdup (path);
entry->loaded_plugins = g_hash_table_new (NULL, NULL);
factory->paths = g_list_prepend (factory->paths, entry);
return TRUE;
}
static LoadedPlugin *
get_already_loaded_module (GlueFactory *factory,
const gchar *component_name,
const gchar *type_name)
{
GList *p;
p = factory->paths;
while (p)
{
PathEntry *entry = p->data;
LoadedPlugin *plugin;
plugin = g_hash_table_lookup (entry->loaded_plugins, component_name);
if (plugin && (* plugin->get_type_func) (plugin->plugin, type_name) != G_TYPE_INVALID)
return plugin;
p = p->next;
}
return NULL;
}
static LoadedPlugin *
load_plugin (GlueFactory *factory, const gchar *component_name, const gchar *type_name)
{
GList *p;
gchar *plugin_name;
p = factory->paths;
plugin_name = g_module_build_path (NULL, component_name);
while (p)
{
const gchar *file_name;
PathEntry *entry = p->data;
GDir *dir;
dir = g_dir_open (entry->path, 0, NULL);
if (dir == NULL)
continue;
do {
file_name = g_dir_read_name (dir);
if (file_name && strcmp (file_name, plugin_name) == 0) {
GModule *module;
GluePlugin *glue_plugin;
gchar *plugin_path;
GluePluginGetTypeFunc get_type_func;
LoadedPlugin *plugin;
/* We have found a matching module */
plugin_path = g_module_build_path (entry->path, plugin_name);
module = g_module_open (plugin_path, 0);
if (module == NULL)
{
g_print ("couldn't open module: %s\n", g_module_error ());
goto move_to_next_dir;
}
if (!g_module_symbol (module, "glue_get_component_type", (gpointer *)&get_type_func))
{
g_module_close (module);
goto move_to_next_dir;
}
/* Now create a new glue plugin */
glue_plugin = glue_plugin_new (module);
if ((* get_type_func) (glue_plugin, type_name) == G_TYPE_INVALID)
{
g_object_unref (glue_plugin);
g_module_close (module);
goto move_to_next_dir;
}
/* Everything seems to be in order */
plugin = g_new (LoadedPlugin, 1);
plugin->plugin = glue_plugin;
plugin->get_type_func = get_type_func;
plugin->name = g_strdup (component_name);
g_type_module_set_name (G_TYPE_MODULE (plugin->plugin), plugin->name);
g_hash_table_insert (entry->loaded_plugins, (gpointer)plugin->name, plugin);
g_dir_close (dir);
g_free (plugin_name);
return plugin;
}
} while (file_name != NULL);
move_to_next_dir:
g_dir_close (dir);
p = p->next;
}
g_free (plugin_name);
return NULL;
}
GType
glue_factory_get_object_type (GlueFactory *factory,
const gchar *component_name,
const gchar *type_name)
{
LoadedPlugin *plugin;
plugin = get_already_loaded_module (factory, component_name, type_name);
if (!plugin)
plugin = load_plugin (factory, component_name, type_name);
if (plugin) {
return (* plugin->get_type_func) (plugin->plugin, type_name);
}
else
return G_TYPE_INVALID;
}
#ifndef __GLUE_FACTORY_H__
#define __GLUE_FACTORY_H__
#include <glib-object.h>
#define GLUE_TYPE_FACTORY (glue_factory_get_type ())
#define GLUE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLUE_TYPE_FACTORY, GlueFactory))
#define GLUE_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLUE_TYPE_FACTORY, GlueFactoryClass))
#define GLUE_IS_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLUE_TYPE_FACTORY))
#define GLUE_IS_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GLUE_TYPE_FACTORY))
#define GLUE_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GLUE_TYPE_FACTORY, GlueFactoryClass))
typedef struct _GlueFactory GlueFactory;
typedef struct _GlueFactoryClass GlueFactoryClass;
GType glue_factory_get_type (void);
GlueFactory *glue_factory_new (void);
gboolean glue_factory_add_path (GlueFactory *factory,
const char *path);
GType glue_factory_get_object_type (GlueFactory *factory,
const gchar *component_name,
const gchar *type_name);
GObject *glue_factory_create_object (GlueFactory *factory,
const gchar *component_name,
const gchar *type_name,
...);
#endif /* __GLUE_FACTORY_H__ */
#include "glue-plugin.h"
static void glue_plugin_init (GluePlugin *plugin);
static void glue_plugin_class_init (GluePluginClass *class);
typedef void (*GluePluginRegisterComponentsFunc) (GluePlugin *plugin);
GType
glue_plugin_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo type_info =
{
sizeof (GluePluginClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) glue_plugin_class_init,
(GClassFinalizeFunc) NULL,
NULL,
sizeof (GluePlugin),
0, /* n_preallocs */
(GInstanceInitFunc) glue_plugin_init,
};
type = g_type_register_static (G_TYPE_TYPE_MODULE,
"GluePlugin",
&type_info, 0);
}
return type;
}
static gboolean
glue_plugin_load (GTypeModule *module)
{
GluePlugin *plugin = GLUE_PLUGIN (module);
GluePluginRegisterComponentsFunc func;
/* Check if we're already loaded */
if (plugin->module)
return TRUE;
/* Load the module and register the plugins */
plugin->module = g_module_open (plugin->path, 0);
if (!plugin->module)
{
g_warning ("could not load plugin: %s", g_module_error ());
return FALSE;
}
if (!g_module_symbol (plugin->module, "glue_register_components", (gpointer *)&func))
{
g_warning ("could not load plugin: %s", g_module_error ());
g_module_close (plugin->module);
plugin->module = NULL;
return FALSE;
}
(* func) (plugin);
return TRUE;
}
static void
glue_plugin_unload (GTypeModule *module)
{
GluePlugin *plugin = GLUE_PLUGIN (module);
if (!plugin->path)
plugin->path = g_strdup (g_module_name (plugin->module));
g_module_close (plugin->module);
plugin->module = NULL;
}
static void
glue_plugin_class_init (GluePluginClass *class)
{
GTypeModuleClass *type_module_class;
type_module_class = (GTypeModuleClass *)class;
type_module_class->load = glue_plugin_load;
type_module_class->unload = glue_plugin_unload;
}
static void
glue_plugin_init (GluePlugin *plugin)
{
}
GluePlugin *
glue_plugin_new (GModule *module)
{
GluePlugin *plugin;
plugin = g_object_new (GLUE_TYPE_PLUGIN, NULL);
plugin->module = module;
return plugin;
}
#ifndef __GLUE_PLUGIN_H__
#define __GLUE_PLUGIN_H__
#include <glib-object.h>
#include <gmodule.h>
#define GLUE_TYPE_PLUGIN (glue_plugin_get_type ())
#define GLUE_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLUE_TYPE_PLUGIN, GluePlugin))
#define GLUE_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLUE_TYPE_PLUGIN, GluePluginClass))
#define GLUE_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLUE_TYPE_PLUGIN))
#define GLUE_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GLUE_TYPE_PLUGIN))
#define GLUE_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GLUE_TYPE_PLUGIN, GluePluginClass))
typedef struct _GluePlugin GluePlugin;
typedef struct _GluePluginClass GluePluginClass;
typedef struct _GluePluginComponent GluePluginComponent;
typedef GType (* GluePluginComponentGetTypeFunc) (GluePlugin *plugin);
struct _GluePlugin
{
GTypeModule parent;
GModule *module;
char *path;
};
struct _GluePluginClass
{
GTypeModuleClass parent_class;
};
struct _GluePluginComponent
{
const gchar *name;
GluePluginComponentGetTypeFunc get_type_func;
};
GType glue_plugin_get_type (void);
GluePlugin *glue_plugin_new (GModule *module);
#define GLUE_PLUGIN_MODULE(components) \
GLUE_REGISTER_COMPONENTS(components) \
GLUE_GET_COMPONENT_TYPE(components)
#define GLUE_REGISTER_COMPONENTS(components) \
G_MODULE_EXPORT void \
glue_register_components (GluePlugin *plugin) \
{ \
int i; \
\
for (i = 0; components[i].name != NULL; i++) \
{ \
(* components[i].get_type_func) (plugin); \
} \
}
#define GLUE_GET_COMPONENT_TYPE(components) \
G_MODULE_EXPORT GType \
glue_get_component_type (GluePlugin *plugin, const char *name) \
{ \
int i; \
\
for (i = 0; components[i].name != NULL; i++) \
{ \
if (strcmp (name, components[i].name) == 0) \
return (* components[i].get_type_func) (plugin); \
} \
\
return G_TYPE_INVALID; \
}
#endif /* __GLUE_PLUGIN_H__ */
#include <config.h>
#include <gnome.h>
#include "gbf-backend.h"
int main (int argc, char **argv)
{
GSList *l;
gnome_program_init ("libgbf-test", VERSION, LIBGNOME_MODULE,
argc, argv, NULL);
g_print ("initializing gbf backend...\n");
gbf_backend_init ();
g_print ("backends found:\n");
for (l = gbf_backend_get_backends (); l; l = l->next) {
GbfBackend *backend = l->data;
g_print ("id : %s\n", backend->id);
g_print ("name : %s\n", backend->name);
g_print ("description: %s\n\n", backend->description);
}
g_print ("done\n");
return 0;
}
? symbol-browser.patch
Index: symbol-browser-tool.c
===================================================================
RCS file: /cvs/gnome/anjuta2/plugins/symbol-browser/symbol-browser-tool.c,v
retrieving revision 1.8
diff -u -r1.8 symbol-browser-tool.c
--- symbol-browser-tool.c 8 Jun 2002 23:12:24 -0000 1.8
+++ symbol-browser-tool.c 23 Aug 2002 12:44:09 -0000
@@ -22,7 +22,7 @@
#include <gnome.h>
#include <bonobo.h>
#include <gdl/gdl.h>
-#include <gbf/gnome-build.h>
+#include <gbf/gbf-project.h>
#include <bonobo-activation/bonobo-activation.h>
#include <libanjuta/libanjuta.h>
@@ -91,31 +91,22 @@
gpointer user_data)
{
CORBA_Environment ev;
- GNOME_Development_Project project;
- Bonobo_PropertyBag pb;
- CORBA_char *dir;
+ GbfProject *project;
+ char *dir;
SymbolBrowserTool *tool = (SymbolBrowserTool *)user_data;
- CORBA_exception_init (&ev);
-
project = g_value_get_pointer (value);
-
- pb = Bonobo_Unknown_queryInterface (project,
- "IDL:Bonobo/PropertyBag:1.0",
- &ev);
- g_assert (!BONOBO_EX (&ev));
-
+ g_assert (GBF_IS_PROJECT (project));
+
/* get directory of current project. */
- dir = bonobo_pbclient_get_string (pb, "project-dir", &ev);
- g_assert (!BONOBO_EX (&ev));
-
+ g_object_get (G_OBJECT (project), "project-dir", &dir, NULL);
+
+ CORBA_exception_init (&ev);
+
/* load the symbols for the current project. */
GNOME_Development_SymbolBrowser_openDirectory (tool->symbol_browser,
dir,
&ev);
- bonobo_object_release_unref (pb, &ev);
-
- g_free (dir);
g_assert (!BONOBO_EX (&ev));
CORBA_exception_free (&ev);
? project-manager.patch
Index: anjuta-project-manager.xml
===================================================================
RCS file: /cvs/gnome/anjuta2/plugins/project-manager/anjuta-project-manager.xml,v
retrieving revision 1.9
diff -u -r1.9 anjuta-project-manager.xml
--- anjuta-project-manager.xml 21 May 2002 23:00:25 -0000 1.9
+++ anjuta-project-manager.xml 23 Aug 2002 12:43:49 -0000
@@ -17,27 +17,57 @@
<cmd name="ProjectRemoveSource" _label="_Remove Source"
_tip="Remove source from project"/>
+
+ <cmd name="BuildAll" _label="All" _tip="Build the project"
+ pixtype="filename" pixname="gbf-build.png" sensitive="0"/>
+
+ <cmd name="BuildInstall" _label="Install" _tip="Install the project"
+ pixtype="filename" pixname="gbf-install.png" sensitive="0"/>
+
+ <cmd name="BuildRun" _label="Run" _tip="Run the project"
+ stockid="gtk-execute" sensitive="0"/>
+
+ <cmd name="BuildParameters" _label="Parameters"
+ _tip="Set the run parameters" sensitive="0"/>
</commands>
<menu>
- <submenu name="File" _label="_File">
- <placeholder name="ProjectOps">
+ <submenu name="File" _label="_File">
+ <placeholder name="ProjectOps">
<menuitem name="ProjectNew" _label="Ne_w Project" verb=""/>
<menuitem name="ProjectOpen" _label="Op_en Project" verb=""/>
<menuitem name="ProjectClose" _label="C_lose Project" verb=""/>
-</placeholder>
- </submenu>
-<submenu name="Project">
-<placeholder name="Sources">
+ </placeholder>
+ </submenu>
+ <submenu name="Project">
+ <placeholder name="Sources">
<menuitem name="ProjectAddSource" verb=""/>
<menuitem name="ProjectRemoveSource" verb=""/>
-</placeholder>
-</submenu>
+ </placeholder>
+ </submenu>
+
+ <placeholder name="BuildMenu">
+ <submenu name="Build" _label="_Build">
+ <menuitem name="BuildAll" verb=""/>
+ <menuitem name="BuildInstall" verb=""/>
+ <separator/>
+ <menuitem name="BuildRun" verb=""/>
+ <menuitem name="BuildParameters" verb=""/>
+ </submenu>
+ </placeholder>
</menu>
<dockitem name="Project" homogeneous="0" band_num="1" in_new_band="0" look="both_horiz">
<toolitem name="ProjectNew" verb=""/>
<toolitem name="ProjectOpen" verb="" priority="1"/>
<toolitem name="ProjectClose" verb=""/>
+ </dockitem>
+
+ <dockitem name="Build" homogeneous="0" band_num="2" in_new_band="0" look="both_horiz">
+ <placeholder name="BuildToolbar">
+ <toolitem name="BuildAll" verb=""/>
+ <toolitem name="BuildInstall" verb=""/>
+ <toolitem name="BuildRun" verb=""/>
+ </placeholder>
</dockitem>
</Root>
Index: project-tool.c
===================================================================
RCS file: /cvs/gnome/anjuta2/plugins/project-manager/project-tool.c,v
retrieving revision 1.31
diff -u -r1.31 project-tool.c
--- project-tool.c 8 Jun 2002 23:15:53 -0000 1.31
+++ project-tool.c 23 Aug 2002 12:43:50 -0000
@@ -1,40 +1,51 @@
-/* Anjuta Project Manager component, based on gnome-build2 */
+/* Anjuta
+ * Copyright (C) 2001 JP Rosevear
+ *
+ * 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.
+ *
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
#include <config.h>
-
-#include <bonobo/bonobo-shlib-factory.h>
-#include <bonobo/bonobo-moniker-util.h>
-#include <bonobo/bonobo-property-bag-client.h>
-#include <bonobo-activation/bonobo-activation.h>
-#include <bonobo/bonobo-ui-component.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <string.h>
#include <bonobo/bonobo-ui-util.h>
#include <bonobo/bonobo-file-selector-util.h>
-#include <bonobo/bonobo-widget.h>
-#include <bonobo/bonobo-window.h>
-#include <gbf/gnome-build.h>
+#include <gconf/gconf-client.h>
+#include <gdl/gdl.h>
+#include <gbf/gbf-backend.h>
+#include <gbf/gbf-project-tree.h>
+#include <gbf/gbf-target-tree.h>
+#include <gbf/gbf-build-info.h>
#if 0
#include <gbf-project-druid/gbf-project-druid.h>
#include <gbf-project-druid/gbf-druid-bonobo-project.h>
#endif
-#include <gconf/gconf-client.h>
-#include <gdl/gdl.h>
-#include <libgnomevfs/gnome-vfs.h>
#include <libanjuta/libanjuta.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <string.h>
+#include <libgnomevfs/gnome-vfs.h>
#define RECENT_PROJECTS_LIMIT "/apps/anjuta2/plugins/project_manager/recent_projects_limit"
typedef struct {
AnjutaTool parent;
- Bonobo_Control file_tree;
- Bonobo_Control target_tree;
- Bonobo_Control build_info;
-
- GNOME_Development_Project project;
- GNOME_Development_Target *current_target;
+ GtkWidget *file_tree;
+ GtkWidget *target_tree;
+ GtkWidget *build_info;
+
+ GbfProject *project;
+ GbfProjectTarget *current_target;
GdlRecent *recent;
} ProjectTool;
@@ -44,35 +55,35 @@
} ProjectToolClass;
static void
-open_file (ProjectTool *tool, GNOME_Development_Source source, int line_num, CORBA_Environment *ev)
+open_file (ProjectTool *tool,
+ const char *filename,
+ int line_num)
{
gboolean res;
- res = anjuta_show_file (ANJUTA_TOOL (tool), source);
+ res = anjuta_show_file (ANJUTA_TOOL (tool), filename);
if (!res) {
anjuta_dialog_error (_("Unable to open file."));
return;
}
-
+
if (line_num != 0)
anjuta_set_line_num (ANJUTA_TOOL (tool), line_num);
}
static void
-set_current_target (ProjectTool *tool, GNOME_Development_Target *target)
+set_current_target (ProjectTool *tool, GbfProjectTarget *target)
{
if (tool->current_target) {
anjuta_shell_remove_value (ANJUTA_TOOL (tool)->shell,
"CurrentTarget",
NULL);
-
- CORBA_free (tool->current_target);
+
tool->current_target = NULL;
}
-
+
if (target) {
- tool->current_target = ORBit_copy_value (target,
- TC_GNOME_Development_Target);
+ tool->current_target = target;
anjuta_shell_add (ANJUTA_TOOL (tool)->shell,
"CurrentTarget",
G_TYPE_POINTER,
@@ -82,148 +93,77 @@
}
static void
-event_cb (BonoboListener *listener, const char *event,
- CORBA_any *any, CORBA_Environment *ev,
- gpointer user_data)
-{
- ProjectTool *tool = (ProjectTool*)user_data;
-
- if (!strcmp (event, "file-selected")) {
- GNOME_Development_Source source = BONOBO_ARG_GET_STRING (any);
-
- open_file (tool, source, 0, ev);
- } else if (!strcmp (event, "target-selected")) {
- set_current_target (tool, any->_value);
- } else if (!strcmp (event, "error-selected")) {
- GNOME_Development_BuildError *build_err = any->_value;
-
- open_file (tool, build_err->source, build_err->line, ev);
- }
-}
-
-static GNOME_Development_Project
-activate_id (const Bonobo_ActivationID id)
-{
- CORBA_Object object = CORBA_OBJECT_NIL;
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
-
- object = bonobo_get_object (id, "IDL:GNOME/Development/Project:1.0", &ev);
-
- if (BONOBO_EX (&ev))
- object = CORBA_OBJECT_NIL;
-
- CORBA_exception_free (&ev);
-
- return (GNOME_Development_Project) object;
-}
-
-static void
set_build (ProjectTool *proj_tool, const gchar *path)
{
AnjutaTool *tool = ANJUTA_TOOL (proj_tool);
- CORBA_Environment ev;
- Bonobo_PropertyBag pb;
- BonoboArg *arg;
- GNOME_Development_Project project = CORBA_OBJECT_NIL;
-
+ GbfProject *project = NULL;
+ GSList *l;
+ GError *err = NULL;
+
g_return_if_fail (tool != NULL);
g_return_if_fail (ANJUTA_IS_TOOL (tool));
-
- GDL_TRACE_EXTRA ("%s", path);
-
- CORBA_exception_init (&ev);
+ /* Close any open project first. */
if (proj_tool->project) {
anjuta_shell_remove_value (tool->shell,
- "CurrentProject",
- NULL);
- bonobo_object_release_unref (proj_tool->project, &ev);
- proj_tool->project = CORBA_OBJECT_NIL;
+ "CurrentProject",
+ NULL);
+ g_object_unref (proj_tool->project);
+ proj_tool->project = NULL;
}
if (path != NULL) {
- Bonobo_ServerInfoList *result = NULL;
- gboolean bail_out = FALSE;
+ GbfBackend *backend = NULL;
+
+ gbf_backend_init ();
- /* Get a project */
- result = bonobo_activation_query (
- "repo_ids.has ('IDL:GNOME/Development/Build:1.0')", NULL, &ev);
-
- if (BONOBO_EX (&ev) ||
- result->_length == 0 ||
- (project = activate_id (result->_buffer[0].iid))
- == CORBA_OBJECT_NIL) {
- bail_out = TRUE;
+ /* FIXME: Allow different project backends (use druid). */
+ for (l = gbf_backend_get_backends (); l; l = l->next) {
+ backend = l->data;
+ if (!strcmp (backend->id, "gbf-am:GbfAmProject"))
+ break;
+ backend = NULL;
}
-
- if (result)
- CORBA_free (result);
- if (bail_out) {
- anjuta_dialog_error (_("Could not activate the "
- "project component"));
- CORBA_exception_free (&ev);
+ if (!backend) {
+ anjuta_dialog_error (_("No project backends found"));
return;
- };
+ }
+
+ project = gbf_backend_new_project (backend->id);
+ if (!project) {
+ anjuta_dialog_error (_("Could not create project object"));
+ return;
+ }
/* Try to load the project */
- GNOME_Development_Project_load (project, path, &ev);
- if (BONOBO_EX (&ev)) {
- if (BONOBO_USER_EX (&ev, ex_GNOME_Development_Project_DoesntExist))
+ GBF_PROJECT_GET_CLASS (project)->load (project, path, &err);
+ if (err != NULL) {
+ if (g_error_matches (err, gbf_project_error_quark (),
+ GBF_PROJECT_ERROR_DOESNT_EXIST)) {
anjuta_dialog_error (_("Project does not exist!"));
- else if (BONOBO_USER_EX (&ev, ex_GNOME_Development_Project_Malformed))
+ } else if (g_error_matches (err, gbf_project_error_quark (),
+ GBF_PROJECT_ERROR_PROJECT_MALFORMED)) {
anjuta_dialog_error (_("Not a proper project!"));
- else
- anjuta_dialog_error (_("Unable to load project!"));
-
- CORBA_exception_free (&ev);
- bonobo_object_release_unref (project, &ev);
+ } else {
+ anjuta_dialog_error (_("Unable to load project"));
+ }
+ g_error_free (err);
return;
- };
+ }
anjuta_shell_add (tool->shell,
"CurrentProject",
G_TYPE_POINTER,
project,
NULL);
-
- proj_tool->project = project;
- }
-
- arg = bonobo_arg_new (TC_GNOME_Development_Project);
- BONOBO_ARG_SET_GENERAL (arg, project, TC_GNOME_Development_Project,
- GNOME_Development_Project, NULL);
- arg->_release = FALSE;
-
- pb = Bonobo_Control_getProperties (proj_tool->file_tree, &ev);
- bonobo_pbclient_set_value (pb, "project", arg, &ev);
- if (BONOBO_EX (&ev)) {
- anjuta_dialog_error (_("Unexpected error while binding the "
- "project to the tree control"));
- CORBA_exception_free (&ev);
- }
-
- pb = Bonobo_Control_getProperties (proj_tool->target_tree, &ev);
- bonobo_pbclient_set_value (pb, "project", arg, &ev);
- if (BONOBO_EX (&ev)) {
- anjuta_dialog_error (_("Unexpected error while binding the "
- "project to the target control"));
- CORBA_exception_free (&ev);
- }
- pb = Bonobo_Control_getProperties (proj_tool->build_info, &ev);
- bonobo_pbclient_set_value (pb, "project", arg, &ev);
- if (BONOBO_EX (&ev)) {
- anjuta_dialog_error (_("Unexpected error while binding the "
- "project to the build info control"));
- CORBA_exception_free (&ev);
+ proj_tool->project = project;
}
- bonobo_arg_release (arg);
-
- CORBA_exception_free (&ev);
+ g_object_set (G_OBJECT (proj_tool->file_tree), "project", project, NULL);
+ g_object_set (G_OBJECT (proj_tool->target_tree), "project", project, NULL);
+ g_object_set (G_OBJECT (proj_tool->build_info), "project", project, NULL);
}
static void
@@ -402,6 +342,30 @@
#endif
}
+static void
+build_all (GtkWidget *widget,
+ gpointer data)
+{
+}
+
+static void
+build_install (GtkWidget *widget,
+ gpointer data)
+{
+}
+
+static void
+build_run (GtkWidget *widget,
+ gpointer data)
+{
+}
+
+static void
+build_params (GtkWidget *widget,
+ gpointer data)
+{
+}
+
static BonoboUIVerb verbs [] = {
BONOBO_UI_UNSAFE_VERB ("ProjectNew", project_new),
BONOBO_UI_UNSAFE_VERB ("ProjectOpen", project_open),
@@ -409,122 +373,124 @@
BONOBO_UI_UNSAFE_VERB ("ProjectAddSource", project_add_source),
BONOBO_UI_UNSAFE_VERB ("ProjectRemoveSource", project_remove_source),
+
+ BONOBO_UI_UNSAFE_VERB ("BuildAll", build_all),
+ BONOBO_UI_UNSAFE_VERB ("BuildInstall", build_install),
+ BONOBO_UI_UNSAFE_VERB ("BuildRun", build_run),
+ BONOBO_UI_UNSAFE_VERB ("BuildParameters", build_params),
+
BONOBO_UI_VERB_END
};
static void
-add_event_listener (AnjutaTool *tool, Bonobo_Control ctrl)
+file_selected_cb (GtkWidget *widget,
+ const char *filename,
+ gpointer user_data)
{
- BonoboListener *listener;
- CORBA_Object source;
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
- listener = bonobo_listener_new (NULL, NULL);
- g_signal_connect (G_OBJECT (listener), "event_notify",
- G_CALLBACK (event_cb), tool);
- source = Bonobo_Unknown_queryInterface (ctrl,
- "IDL:Bonobo/EventSource:1.0",
- &ev);
- if (!CORBA_Object_is_nil (source, &ev) && ev._major == CORBA_NO_EXCEPTION) {
- Bonobo_EventSource_addListener (source, bonobo_object_corba_objref (BONOBO_OBJECT (listener)), &ev);
- } else {
- g_error ("couldn't get event source for project tree widget");
- }
-
- CORBA_exception_free (&ev);
+ open_file (user_data, filename, 0);
}
static void
init_project_tree (AnjutaTool *tool)
{
- GtkWidget *widget;
- ProjectTool *proj_tool = (ProjectTool*)tool;
+ ProjectTool *proj_tool = (ProjectTool *)tool;
- widget = bonobo_widget_new_control
- ("OAFIID:GNOME_Development_ProjectTree",
- BONOBO_OBJREF (bonobo_window_get_ui_container (BONOBO_WINDOW (tool->shell))));
+ proj_tool->file_tree = gbf_project_tree_new ();
+ gtk_widget_show (proj_tool->file_tree);
- if (widget) {
- gtk_widget_show (widget);
-
- anjuta_shell_add_widget (tool->shell, widget,
- "ProjectFileTree",
- _("Files"),
- NULL);
-
- proj_tool->file_tree =
- bonobo_widget_get_objref (BONOBO_WIDGET (widget));
- add_event_listener (tool, proj_tool->file_tree);
- } else {
- g_warning ("Could not initialize project manager.");
+ anjuta_shell_add_widget (tool->shell, proj_tool->file_tree,
+ "ProjectFileTree",
+ _("Files"),
+ NULL);
+
+ g_signal_connect (G_OBJECT (proj_tool->file_tree),
+ "file_selected",
+ G_CALLBACK (file_selected_cb),
+ tool);
+}
+
+static void
+target_selected_cb (GtkWidget *widget,
+ const char *target_id,
+ gpointer user_data)
+{
+ ProjectTool *proj_tool = user_data;
+ GbfProject *project = proj_tool->project;
+ GbfProjectTarget *target;
+ GError *err = NULL;
+
+ target = GBF_PROJECT_GET_CLASS (project)->get_target (project, target_id, &err);
+ if (err) {
+ g_print ("error retrieving target: %s\n", target_id);
+ g_error_free (err);
+ return;
}
+
+ set_current_target (proj_tool, target);
}
static void
init_target_tree (AnjutaTool *tool)
{
- GtkWidget *widget;
- ProjectTool *proj_tool = (ProjectTool*)tool;
+ ProjectTool *proj_tool = (ProjectTool *)tool;
- widget = bonobo_widget_new_control
- ("OAFIID:GNOME_Development_TargetTree",
- BONOBO_OBJREF (bonobo_window_get_ui_container (BONOBO_WINDOW (tool->shell))));
-
- if (widget) {
- gtk_widget_show (widget);
-
- anjuta_shell_add_widget (tool->shell, widget,
- "ProjectTargetTree",
- _("Targets"),
- NULL);
-
- proj_tool->target_tree =
- bonobo_widget_get_objref (BONOBO_WIDGET (widget));
- add_event_listener (tool, proj_tool->target_tree);
- } else {
- g_warning ("Could not initialize project manager.");
- }
+ proj_tool->target_tree = gbf_target_tree_new ();
+ gtk_widget_show (proj_tool->target_tree);
+
+ anjuta_shell_add_widget (tool->shell,
+ proj_tool->target_tree,
+ "ProjectTargetTree",
+ _("Targets"),
+ NULL);
+
+ g_signal_connect (G_OBJECT (proj_tool->target_tree),
+ "file_selected",
+ G_CALLBACK (file_selected_cb),
+ tool);
+ g_signal_connect (G_OBJECT (proj_tool->target_tree),
+ "target_selected",
+ G_CALLBACK (target_selected_cb),
+ tool);
+}
+
+static void
+error_selected_cb (GtkWidget *widget,
+ const char *filename,
+ int line,
+ gpointer user_data)
+{
+ open_file (user_data, filename, line);
}
static void
init_build_info (AnjutaTool *tool)
{
- GtkWidget *widget;
- ProjectTool *proj_tool = (ProjectTool*)tool;
+ ProjectTool *proj_tool = (ProjectTool *)tool;
- widget = bonobo_widget_new_control
- ("OAFIID:GNOME_Development_BuildInfo",
- BONOBO_OBJREF (bonobo_window_get_ui_container (BONOBO_WINDOW (tool->shell))));
-
- if (widget) {
- gtk_widget_show (widget);
-
- anjuta_shell_add_widget (tool->shell, widget,
- "ProjectBuildInfo",
- _("Build"),
- NULL);
-
- proj_tool->build_info =
- bonobo_widget_get_objref (BONOBO_WIDGET (widget));
- add_event_listener (tool, proj_tool->build_info);
- } else {
- g_warning ("Could not initialize project manager.");
- }
+ proj_tool->build_info = gbf_build_info_new ();
+ gtk_widget_show (proj_tool->build_info);
+
+ anjuta_shell_add_widget (tool->shell,
+ proj_tool->build_info,
+ "ProjectBuildInfo",
+ _("Build"),
+ NULL);
+
+ g_signal_connect (G_OBJECT (proj_tool->build_info),
+ "error_selected",
+ G_CALLBACK (error_selected_cb),
+ tool);
}
static void
shell_set (AnjutaTool *tool)
{
- CORBA_Environment ev;
GConfClient *client;
GdlRecent *recent;
ProjectTool *proj_tool = (ProjectTool*)tool;
g_return_if_fail (tool != NULL);
g_return_if_fail (ANJUTA_IS_TOOL (tool));
-
- CORBA_exception_init (&ev);
anjuta_tool_merge_ui (tool, "anjuta-project-manager",
DATADIR,
@@ -551,8 +517,6 @@
gdl_recent_set_ui_component (recent, tool->uic);
proj_tool->recent = recent;
-
- CORBA_exception_free (&ev);
}
static void
@@ -560,11 +524,7 @@
{
AnjutaTool *tool = ANJUTA_TOOL (obj);
ProjectTool *proj_tool = (ProjectTool*)obj;
-
- CORBA_Environment ev;
- CORBA_exception_init (&ev);
-
if (proj_tool->file_tree) {
anjuta_shell_remove_value (tool->shell,
"ProjectFileTree",
@@ -590,9 +550,8 @@
anjuta_shell_remove_value (tool->shell,
"CurrentProject",
NULL);
- bonobo_object_release_unref (proj_tool->build_info, &ev);
+ g_object_unref (proj_tool->project);
proj_tool->project = NULL;
-
}
if (proj_tool->recent) {
@@ -601,8 +560,6 @@
}
anjuta_tool_unmerge_ui (tool);
-
- CORBA_exception_free (&ev);
}
static void
@@ -614,7 +571,7 @@
project_tool_class_init (GObjectClass *klass)
{
AnjutaToolClass *tool_class = ANJUTA_TOOL_CLASS (klass);
-
+
tool_class->shell_set = shell_set;
klass->dispose = dispose;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]