[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: CVS update: pcb.g_dbus.patch
User: pcjc2
Date: 06/10/05 17:49:17
Added: . pcb.g_dbus.patch
Log:
Added patch against PCB CVS HEAD to add basic dbus support for executing
actions.
Revision Changes Path
1.1 eda/geda/xgsch2pcb/support/pcb.g_dbus.patch
Index: pcb.g_dbus.patch
===================================================================
Index: configure.ac
===================================================================
RCS file: /cvsroot/pcb/pcb/configure.ac,v
retrieving revision 1.62
diff -U3 -p -r1.62 configure.ac
--- configure.ac 2 Oct 2006 02:06:31 -0000 1.62
+++ configure.ac 4 Oct 2006 22:41:30 -0000
@@ -177,6 +177,17 @@ then
HIDLIST=
fi
+AC_MSG_CHECKING([for GLIB_DBUS])
+AC_ARG_WITH([dbus],
+[ --with-dbus Specify if DBUS IPC is to be included (only works with gtk GUI)],
+[],[])
+AC_MSG_RESULT([$with_dbus])
+AM_CONDITIONAL(WITH_DBUS, test x$with_dbus = xyes)
+
+if test "x$with_dbus" = "xyes" -a x"$with_gui" != x"gtk"; then
+ AC_MSG_ERROR([DBUS selected, but only works with the GTK gui])
+fi
+
AC_MSG_CHECKING([for which printer to use])
AC_ARG_WITH([printer],
[ --with-printer= Specify the printer: lpr [[default=lpr]]],
@@ -322,6 +333,23 @@ Please review the following errors:
$GLIB_PKG_ERRORS])]
)
GLIB_VERSION=`$PKG_CONFIG glib-2.0 --modversion`
+
+ if test "X$with_dbus" = "Xyes"; then
+ PKG_CHECK_MODULES(DBUS, dbus-1 >= 0.61, ,
+ [AC_MSG_ERROR([Cannot find dbus-1 >= 0.61, install it and rerun ./configure
+ Please review the following errors:
+ $DBUS_PKG_ERRORS])]
+ )
+ DBUS_GLIB_VERSION=`$PKG_CONFIG dbus-glib-1 --modversion`
+ PKG_CHECK_MODULES(DBUS_GLIB, dbus-glib-1 >= 0.20, ,
+ [AC_MSG_ERROR([Cannot find dbus-glib-1 >= 0.20, install it and rerun ./configure
+ Please review the following errors:
+ $DBUS_GLIB_PKG_ERRORS])]
+ )
+ DBUS_GLIB_VERSION=`$PKG_CONFIG dbus-glib-1 --modversion`
+ AC_DEFINE([HAVE_DBUS], 1,
+ [Define to 1 if DBUS IPC is to be compiled in])
+ fi
;;
png )
@@ -494,8 +522,8 @@ fi
AC_MSG_RESULT([no])
])
-CFLAGS="$CFLAGS $X_CFLAGS $GTK_CFLAGS"
-LIBS="$LIBS $XM_LIBS $X_LIBS $GTK_LIBS $DMALLOC_LIBS $GD_LIBS"
+CFLAGS="$CFLAGS $X_CFLAGS $DBUS_GLIB_CFLAGS $GTK_CFLAGS"
+LIBS="$LIBS $XM_LIBS $DBUS_GLIB_LIBS $X_LIBS $GTK_LIBS $DMALLOC_LIBS $GD_LIBS"
# if we have gcc then add -Wall
Index: src/hid/gtk/gui-top-window.c
===================================================================
RCS file: /cvsroot/pcb/pcb/src/hid/gtk/gui-top-window.c,v
retrieving revision 1.31
diff -U3 -p -r1.31 gui-top-window.c
--- src/hid/gtk/gui-top-window.c 24 Sep 2006 21:23:49 -0000 1.31
+++ src/hid/gtk/gui-top-window.c 4 Oct 2006 22:34:17 -0000
@@ -80,6 +80,10 @@
#include "gui-icons-mode-buttons.data"
#include "gui-icons-misc.data"
+#ifdef HAVE_DBUS
+#include "dbus.h"
+#endif
+
#ifdef HAVE_LIBDMALLOC
#include <dmalloc.h>
#endif
@@ -3839,6 +3843,10 @@ ghid_do_export (HID_Attr_Val * options)
if (stdin_listen)
ghid_create_listener ();
+#ifdef HAVE_DBUS
+ ghid_dbus_setup();
+#endif
+
gtk_main ();
ghid_config_files_write ();
}
Index: src/hid/gtk/dbus.c
===================================================================
diff -U3 -p -r -N /home/pcjc2/empty/dbus.c src/hid/gtk/dbus.c
--- /home/pcjc2/empty/dbus.c 1970-01-01 01:00:00.000000000 +0100
+++ src/hid/gtk/dbus.c 2006-10-04 19:59:11.000000000 +0100
@@ -0,0 +1,158 @@
+/*
+ * PCB, an interactive printed circuit board editor
+ * D-Bus IPC logic
+ * Copyright (C) 2006 University of Cambridge
+ *
+ * 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
+ */
+
+/*
+ * D-Bus code derrived from example-service.c in the dbus-glib bindings
+ */
+
+#include "dbus.h"
+#include "data.h"
+
+#include <dbus/dbus-glib.h>
+
+typedef struct GhidDbus GhidDbus;
+typedef struct GhidDbusClass GhidDbusClass;
+
+GType ghid_dbus_get_type (void);
+
+struct GhidDbus
+{
+ GObject parent;
+};
+
+struct GhidDbusClass
+{
+ GObjectClass parent;
+};
+
+#define GHID_TYPE_DBUS (ghid_dbus_get_type ())
+#define GHID_DBUS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GHID_TYPE_DBUS, GhidDbus))
+#define GHID_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GHID_TYPE_DBUS, GhidDbusClass))
+#define GHID_IS_DBUS(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GHID_TYPE_DBUS))
+#define GHID_IS_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GHID_TYPE_DBUS))
+#define GHID_DBUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GHID_TYPE_DBUS, GhidDbusClass))
+
+G_DEFINE_TYPE(GhidDbus, ghid_dbus, G_TYPE_OBJECT)
+
+gboolean ghid_dbus_get_filename (GhidDbus *obj, char **ret, GError **error);
+gboolean ghid_dbus_exec_action (GhidDbus *obj, char *action, char **args, guint32 *ret, GError **error);
+
+#include "dbus-glue.h"
+
+static void
+ghid_dbus_init (GhidDbus *obj)
+{
+}
+
+static void
+ghid_dbus_class_init (GhidDbusClass *klass)
+{
+}
+
+gboolean
+ghid_dbus_get_filename (GhidDbus *obj, char **ret, GError **error)
+{
+#ifdef DEBUGDBUS
+ printf ("ghid_dbus_get_filename()\n");
+#endif
+ (*ret) = g_strdup ( PCB->Filename );
+
+ return TRUE;
+}
+
+gboolean
+ghid_dbus_exec_action (GhidDbus *obj, char *action, char **args, guint32 *ret, GError **error)
+{
+ char *arg;
+ int i;
+
+#ifdef DEBUGDBUS
+ printf( "ghid_dbus_exec_action()\n Got action = '%s'\n", action);
+#endif
+
+ for (i=0; args[i] != NULL; i++) {
+ arg = args[i];
+#ifdef DEBUGDBUS
+ printf( " Got argument #%i = '%s'\n", i, arg );
+#endif
+ }
+
+#ifdef DEBUGDBUS
+ printf ( " Argument count, i=%i\n", i );
+#endif
+
+ hid_actionv( action, i, args );
+
+ // TODO: Dummy return code for now, in the future we want a code from the action
+ (*ret) = 0;
+
+ return TRUE;
+}
+
+void
+ghid_dbus_setup ( void )
+{
+ DBusGConnection *bus;
+ DBusGProxy *bus_proxy;
+ GError *error = NULL;
+ GhidDbus *obj;
+ guint request_name_result;
+
+ dbus_g_object_type_install_info (GHID_TYPE_DBUS, &dbus_glib_ghid_dbus_object_info);
+
+ bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ if (!bus)
+ {
+ g_message ("Couldn't connect to session bus: %s", error->message );
+ g_error_free (error);
+ return;
+ }
+
+ bus_proxy = dbus_g_proxy_new_for_name (bus,
+ "org.freedesktop.DBus",
+ "/org/freedesktop/DBus",
+ "org.freedesktop.DBus");
+
+ if (!dbus_g_proxy_call (bus_proxy, "RequestName", &error,
+ G_TYPE_STRING, "org.seul.geda.pcb",
+ G_TYPE_UINT, 0,
+ G_TYPE_INVALID,
+ G_TYPE_UINT, &request_name_result,
+ G_TYPE_INVALID))
+ {
+ g_message ("Failed to acquire org.seul.geda.pcb: %s", error->message );
+ g_error_free (error);
+ g_object_unref( bus_proxy );
+ dbus_g_connection_unref( bus );
+ return;
+ }
+
+ g_object_unref( bus_proxy );
+
+ obj = g_object_new (GHID_TYPE_DBUS, NULL);
+
+ dbus_g_connection_register_g_object (bus, "/org/seul/geda/pcb", G_OBJECT (obj));
+
+ // TODO: Find out if this is needed
+ dbus_g_connection_unref( bus );
+
+ return;
+}
+
Index: src/hid/gtk/dbus.h
===================================================================
diff -U3 -p -r -N /home/pcjc2/empty/dbus.h src/hid/gtk/dbus.h
--- /home/pcjc2/empty/dbus.h 1970-01-01 01:00:00.000000000 +0100
+++ src/hid/gtk/dbus.h 2006-10-03 22:15:24.000000000 +0100
@@ -0,0 +1,27 @@
+/*
+ * PCB, an interactive printed circuit board editor
+ * D-Bus IPC logic
+ * Copyright (C) 2006 University of Cambridge
+ *
+ * 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
+ */
+#ifndef _DBUS_H_
+#define _DBUS_H_
+
+/* Carry out all actions to setup the D-Bus and register signal handlers */
+void ghid_dbus_setup();
+
+
+#endif /* !_DBUS_H */
Index: src/hid/gtk/dbus.xml
===================================================================
diff -U3 -p -r -N /home/pcjc2/empty/dbus.xml src/hid/gtk/dbus.xml
--- /home/pcjc2/empty/dbus.xml 1970-01-01 01:00:00.000000000 +0100
+++ src/hid/gtk/dbus.xml 2006-10-04 01:23:43.000000000 +0100
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!-- Should name="/org/geda/seul/pcb" ? -->
+<node name="/">
+ <interface name="org.seul.geda.pcb">
+ <method name="GetFilename">
+ <arg direction="out" type="s" />
+ </method>
+ </interface>
+ <interface name="org.seul.geda.pcb.actions">
+ <method name="ExecAction">
+ <arg direction="in" type="s" name="action" />
+ <arg direction="in" type="as" name="args" />
+ <arg direction="out" type="u" />
+ </method>
+ </interface>
+</node>
+
Index: src/Makefile.am
===================================================================
RCS file: /cvsroot/pcb/pcb/src/Makefile.am,v
retrieving revision 1.29
diff -U3 -p -r1.29 Makefile.am
--- src/Makefile.am 10 Aug 2006 16:27:15 -0000 1.29
+++ src/Makefile.am 4 Oct 2006 23:38:50 -0000
@@ -167,6 +167,7 @@ EXTRA_DIST= \
$(srcdir)/hid/gtk/gui-icons-mode-buttons.data \
$(srcdir)/hid/gtk/hid.conf \
$(srcdir)/hid/gtk/pcb.rc \
+ $(srcdir)/hid/gtk/dbus.xml \
$(srcdir)/hid/lesstif/hid.conf \
$(srcdir)/hid/lpr/hid.conf \
$(srcdir)/hid/png/hid.conf \
@@ -214,11 +215,25 @@ LIBGTK_SRCS = \
hid/gtk/gui-utils.c
libgtk_a_SOURCES = ${LIBGTK_SRCS} hid/gtk/gtk_lists.h
+EXTRA_libgtk_a_SOURCES = \
+ hid/gtk/dbus.c \
+ hid/gtk/dbus.h
+
hid/gtk/gtk_lists.h : ${LIBGTK_SRCS} Makefile
true > $@
(for f in ${LIBGTK_SRCS} ; do cat $(srcdir)/$$f ; done) | grep "^REGISTER" > $@.tmp
mv $@.tmp $@
+# If we are building with dbus support, we need some extra files
+if WITH_DBUS
+hid/gtk/dbus-glue.h : $(srcdir)/hid/gtk/dbus.xml Makefile
+ dbus-binding-tool --mode=glib-server --output=$@ --prefix=ghid_dbus $(srcdir)/hid/gtk/dbus.xml
+
+LIBGTK_SRCS+= hid/gtk/dbus.c hid/gtk/dbus.h
+BUILT_SOURCES+= hid/gtk/dbus-glue.h
+
+endif
+
# If we are building on win32, then compile in some icons for the
# desktop and application toolbar
if WIN32
@@ -307,6 +322,7 @@ DISTCLEANFILES= pcbtest.sh Pcb .test/Pcb
hid/batch/batch_lists.h \
hid/common/hidlist.h \
hid/gtk/gtk_lists.h \
+ hid/gtk/dbus-glue.h \
hid/lesstif/lesstif_lists.h \
hid/png/png_lists.h \
hid/ps/ps_lists.h \
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs