diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2008-11-08 10:26:50 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2008-11-08 10:26:50 +0000 |
commit | 70c136fc29ff84220228e35c6ce26e007d7840d9 (patch) | |
tree | 6098aee354986daa6f2957f4b66ef2023f8f656e | |
parent | 61e5d29d2717ab2bae85fd12e621b35e6463446e (diff) |
Fixup for in-tree CairoScript.
-rw-r--r-- | configure.in | 7 | ||||
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/main.c | 56 | ||||
-rw-r--r-- | src/sphinx.h | 2 |
4 files changed, 47 insertions, 22 deletions
diff --git a/configure.in b/configure.in index f4165ff..72cc30e 100644 --- a/configure.in +++ b/configure.in @@ -21,12 +21,13 @@ AM_GLIB_GNU_GETTEXT GTK_VERSION=2.14.0 GCONF_VERSION=2.14.0 -PKG_CHECK_MODULES(DBG, +PKG_CHECK_MODULES(SPHINX, + cairo-script gconf-2.0 >= $GCONF_VERSION gtk+-2.0 >= $GTK_VERSION gtksourceview-2.0) -AC_SUBST(DBG_CFLAGS) -AC_SUBST(DBG_LIBS) +AC_SUBST(SPHINX_CFLAGS) +AC_SUBST(SPHINX_LIBS) AC_PATH_PROG(GCONFTOOL, gconftool-2, no) diff --git a/src/Makefile.am b/src/Makefile.am index ec6e179..4e98735 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,8 +15,8 @@ sphinx_CPPFLAGS = \ -DSPHINX_SYSCONFDIR=\"$(sysconfdir)/\" \ $(AM_CPPFLAGS) -sphinx_CFLAGS = @DBG_CFLAGS@ -sphinx_LDADD = @DBG_LIBS@ -lcairo-script-interpreter +sphinx_CFLAGS = @SPHINX_CFLAGS@ +sphinx_LDADD = @SPHINX_LIBS@ pixmapdir = $(datadir)/pixmaps pixmap_DATA = \ @@ -18,6 +18,7 @@ #include "sphinx.h" +#include <cairo-script-interpreter.h> #include <gconf/gconf-client.h> #include <gtk/gtk.h> #include <gtksourceview/gtksourceview.h> @@ -27,8 +28,6 @@ #include <gtksourceview/gtksourcestyleschememanager.h> #include <gtksourceview/gtksourceprintcompositor.h> -#include <cairo-script-interpreter.h> - #include <string.h> #include <unistd.h> #include <errno.h> @@ -495,7 +494,23 @@ run_interpreter_cb (GtkAction *action, sphinx_t *sphinx) static void reset_interpreter_cb (GtkAction *action, sphinx_t *sphinx) { - csi_reset_interpreter (sphinx->csi); + //csi_reset_interpreter (sphinx->csi); +} + +static void +set_breakpoint_on_line (sphinx_t *sphinx, GtkTextIter *iter) +{ + GSList *mark_list; + + mark_list = + gtk_source_buffer_get_source_marks_at_line (sphinx->buffer, + gtk_text_iter_get_line + (iter), + GTK_STOCK_NO); + if (mark_list == NULL) { + gtk_source_buffer_create_source_mark (sphinx->buffer, NULL, + GTK_STOCK_NO, iter); + } } static gboolean @@ -537,8 +552,8 @@ button_press_cb (GtkWidget *w, GdkEventButton *ev, sphinx_t *sphinx) static cairo_surface_t * _create_surface (void *closure, - double width, double height, - csi_object_t *dictionary) + double width, double height) + //csi_object_t *dictionary) { return cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); } @@ -553,6 +568,9 @@ surface_view_expose (GtkWidget *w, GdkEventExpose *ev) SurfaceView *self = (SurfaceView *) w; cairo_t *cr; + if (self->surface == NULL) + return TRUE; + cr = gdk_cairo_create (w->window); gdk_cairo_region (cr, ev->region); cairo_clip (cr); @@ -717,8 +735,8 @@ _create_surface_view (sphinx_t *sphinx) static void _destroy_surface (void *closure, - cairo_surface_t *surface, - csi_object_t *dictionary) + void *surface) + //csi_object_t *dictionary) { sphinx_t *sphinx = closure; @@ -745,8 +763,8 @@ _destroy_surface (void *closure, static void _destroy_context (void *closure, - cairo_t *cr, - csi_object_t *dictionary) + void *cr) + //csi_object_t *dictionary) { sphinx_t *sphinx = closure; @@ -866,7 +884,7 @@ sphinx_new (void) "", G_CALLBACK (watch_context_cb), TRUE }, }; - sphinx_t *sphinx; + sphinx_t *sphinx = g_new0 (sphinx_t, 1); GtkWidget *w, *sw, *menu, *notebook; GtkSourceStyleSchemeManager *manager; const gchar * const *ids; @@ -878,13 +896,16 @@ sphinx_new (void) GdkColor color; gchar *str; GError *error = NULL; + const cairo_script_interpreter_hooks_t hooks = { + .closure = sphinx, + .surface_create = _create_surface, + .surface_destroy = _destroy_surface, + .context_destroy = _destroy_context, + }; - sphinx = g_new0 (sphinx_t, 1); + sphinx->csi = cairo_script_interpreter_create (); + cairo_script_interpreter_install_hooks (sphinx->csi, &hooks); - sphinx->csi = csi_create (); - csi_set_surface_create_function (sphinx->csi, _create_surface, sphinx); - csi_set_surface_destroy_function (sphinx->csi, _destroy_surface, sphinx); - csi_set_context_destroy_function (sphinx->csi, _destroy_context, sphinx); sphinx->break_on_surface_undef = FALSE; sphinx->break_on_context_undef = FALSE; sphinx->watch_surfaces = FALSE; @@ -1325,7 +1346,10 @@ sphinx_run_step (sphinx_t *sphinx) } str = gtk_text_iter_get_text (&iter, &sphinx->run_start); - csi_feed_string (sphinx->csi, str, -1); + if (cairo_script_interpreter_feed_string (sphinx->csi, str, -1)) { + set_breakpoint_on_line (sphinx, &iter); + sphinx_run_break (sphinx); + } g_free (str); } diff --git a/src/sphinx.h b/src/sphinx.h index a4eede1..6dad015 100644 --- a/src/sphinx.h +++ b/src/sphinx.h @@ -19,10 +19,10 @@ #ifndef SPHINX_H #define SPHINX_H +#include <cairo-script-interpreter.h> #include <glib.h> #include <gtk/gtk.h> #include <gconf/gconf-client.h> -#include <cairo-script-interpreter.h> #include <gtksourceview/gtksourcebuffer.h> G_BEGIN_DECLS |