]> granicus.if.org Git - graphviz/commitdiff
move browser linkage into generic event code so that clicking on
authorellson <devnull@localhost>
Wed, 28 Jun 2006 14:47:53 +0000 (14:47 +0000)
committerellson <devnull@localhost>
Wed, 28 Jun 2006 14:47:53 +0000 (14:47 +0000)
    objects with urls works in -Txlib as well as -Tgtk

lib/gvc/Makefile.am
lib/gvc/gvevent.c
plugin/gtk/callbacks.c

index fac53f5d0292d7c1ef60f1b004c675c7050be601..0be54a9293680c714d8a5fc29a635d0fb6388cd0 100644 (file)
@@ -10,7 +10,7 @@ AM_CPPFLAGS = \
        -I$(top_srcdir)/lib/graph \
        -I$(top_srcdir)/lib/cdt \
        $(INCLTDL) -I$(top_srcdir)/libltdl \
-       -DGVLIBDIR=\"$(pkglibdir)\"
+       $(GNOMEUI_CFLAGS) -DGVLIBDIR=\"$(pkglibdir)\"
 
 LIBS = $(LIBLTDL) $(SOCKET_LIBS)
 
@@ -35,7 +35,7 @@ libgvc_la_LIBADD = $(libgvc_C_la_LIBADD) \
        $(top_builddir)/lib/cdt/libcdt.la \
        $(top_builddir)/lib/graph/libgraph.la \
        $(top_builddir)/lib/pathplan/libpathplan.la \
-       @EXPAT_LIBS@ @Z_LIBS@
+       @GNOMEUI_LIBS@ @EXPAT_LIBS@ @Z_LIBS@
 
 #For use without plugins.
 #  so it needs to be linked with a preset table of builtins, e.g. dot_builtins.c,
index 23fcd2eeb156088b85da4105c9c55791e6c0bd41..318007f801d6c277d7d2d6043e18db66ca95fb38 100644 (file)
 #include "config.h"
 #endif
 
+#include <string.h>
+
+#ifdef HAVE_GNOMEUI
+#include <libgnome/libgnome.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
 #include "gvplugin_layout.h"
 #include "graph.h"
 #include "gvcint.h"
 #include "gvcproc.h"
 
-#include <string.h>
 extern char *strdup_and_subst_graph(char *str, Agraph_t * g);
 extern char *strdup_and_subst_edge(char *str, Agedge_t * e);
 extern char *strdup_and_subst_node(char *str, Agnode_t * n);
@@ -432,6 +446,30 @@ static void gvevent_button_release(GVJ_t *job, int button, pointf pointer)
 {
     job->click = 0;
     job->button = 0;
+    if (job->selected_href && job->selected_href[0]) {
+#ifdef HAVE_GNOMEUI
+        gnome_url_show(job->selected_href, NULL);
+#else
+#if defined HAVE_SYS_TYPES_H && defined HAVE_UNISTD_Y && defined HAVE_ERRNO_H
+        char *exec_argv[3] = {"firefox", NULL, NULL};
+        pid_t pid;
+        int err;
+
+        exec_argv[1] = job->selected_href;
+
+        pid = fork();
+        if (pid == -1) {
+            fprintf(stderr,"fork failed: %s\n", strerror(errno));
+        }
+        else if (pid == 0) {
+            err = execvp(exec_argv[0], exec_argv);
+            fprintf(stderr,"error starting %s: %s\n", exec_argv[0], strerror(errno));
+        }
+#else
+       fprintf(stdout,"%s\n", job->selected_href);
+#endif
+#endif
+    }
 }
 
 static void gvevent_motion(GVJ_t * job, pointf pointer)
index 6ae63d2ba58fc8a15ae383c5da937058cc3e5f67..deb5b035fdc1b5e7885febb5a8fdef382809fb41 100644 (file)
 #endif
 
 #include <gtk/gtk.h>
-#ifdef HAVE_GNOMEUI
-#include <libgnome/libgnome.h>
-#else
-#include <stdio.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#endif
 
 #include "gvplugin_device.h"
 
@@ -377,30 +368,6 @@ on_drawingarea1_button_press_event     (GtkWidget       *widget,
     (job->callbacks->button_press)(job, event->button, pointer);
     
     load_store_with_attrs(GTK_LIST_STORE(g_object_get_data(G_OBJECT(widget), "attr_store")), job);
-
-    if (job->selected_href && job->selected_href[0]) {
-#if 0
-       fprintf(stderr,"href = \"%s\"\n", job->selected_href);
-#endif
-#ifdef HAVE_GNOMEUI
-       gnome_url_show(job->selected_href, NULL);
-#else
-       char *exec_argv[3] = {"firefox", NULL, NULL};
-       pid_t pid;
-       int err;
-
-       exec_argv[1] = job->selected_href;
-
-       pid = fork();
-       if (pid == -1) {
-           fprintf(stderr,"fork failed: %s\n", strerror(errno));
-       }
-       else if (pid == 0) {
-           err = execvp(exec_argv[0], exec_argv);
-           fprintf(stderr,"error starting %s: %s\n", exec_argv[0], strerror(errno));
-       }
-#endif
-    }
     return FALSE;
 }