Re: scintilla configuration patch



OK,

I *think* i've got configure.in & Makefile.am so far that they'll
install the scintilla.schemas file. Replace the previous
gdl_bonobo-conf.patch with this new one please.

Thanks,

Jeroen
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gdl/ChangeLog,v
retrieving revision 1.25
diff -u -r1.25 ChangeLog
--- ChangeLog	2001/07/20 04:35:16	1.25
+++ ChangeLog	2001/08/05 19:23:52
@@ -1,3 +1,13 @@
+2001-08-05  Jeroen Zwartepoorte <Jeroen xs4all nl>
+	* scintilla-control/scintilla-control.c
+	  scintilla-control/scintilla-property-control.h
+	  scintilla-control/scintilla-property-control.c: Added bonobo-conf 
+	PropertyControl interface support and implementation of line-numbers, 
+	whitespace, vieweol, tabwidth and usetabchar properties
+	(scintilla_set_* methods in scintilla-control.c).
+	
+	* configure.in: Added bonobo-conf-0.10 dependency
+
 2001-07-20  Dave Camp  <dave ximian com>
 
         * Applied a patch from Gustavo M. Giraldez <gustavo giraldez gmx net>
Index: configure.in
===================================================================
RCS file: /cvs/gnome/gdl/configure.in,v
retrieving revision 1.7
diff -u -r1.7 configure.in
--- configure.in	2001/07/09 10:21:38	1.7
+++ configure.in	2001/08/05 19:23:52
@@ -59,6 +59,21 @@
 	eval $tmp_bsnom'_LIBS'=\"`gnome-config --libs $pkgname`\"
 ])
 
+
+dnl Specify the configuration source, default to xml::$(sysconfdir)/gconf/gconf.xml.defaults
+
+GCONF_CONFIG_SOURCE=
+AC_ARG_ENABLE(gconf-source, 
+            [  --enable-gconf-source=sourceaddress      Where to install schema files.],GCONF_CONFIG_SOURCE=$enable_gconf_source,)
+
+if test "x$GCONF_CONFIG_SOURCE" = "x"; then
+        GCONF_CONFIG_SOURCE="xml::\${sysconfdir}/gconf/gconf.xml.defaults"
+        INSTALL_GCONF_CONFIG_SOURCE="xml::\$(DESTDIR)\${sysconfdir}/gconf/gconf.xml.defaults"
+fi
+
+AC_SUBST(GCONF_CONFIG_SOURCE)
+AC_SUBST(INSTALL_GCONF_CONFIG_SOURCE)
+
 dnl libtool versioning
 
 dnl gdl-0.1.0 = 0
@@ -107,8 +122,9 @@
 dnl ***************
 
 CHECK_LIB(gnome-libs, gnome, 1.2.9)
-CHECK_LIB(Bonobo, bonobo, 1.0.7)
-CHECK_LIB(Bonobo X, bonobox, 1.0.7)
+CHECK_LIB(bonobo, bonobo, 1.0.7)
+CHECK_LIB(bonobox, bonobox, 1.0.7)
+CHECK_LIB(bonobo-conf, bonobo_conf, 0.10)
 CHECK_LIB(OAF, oaf, 0.6.5)
 CHECK_LIB(GNOME-VFS, vfs, 1.0)
 
@@ -118,6 +134,8 @@
 AC_SUBST(BONOBO_LIBS)
 AC_SUBST(BONOBOX_CFLAGS)
 AC_SUBST(BONOBOX_LIBS)
+AC_SUBST(BONOBO_CONF_CFLAGS)
+AC_SUBST(BONOBO_CONF_LIBS)
 AC_SUBST(OAF_CFLAGS)
 AC_SUBST(VFS_CFLAGS)
 AC_SUBST(VFS_LIBS)
Index: scintilla-control/Makefile.am
===================================================================
RCS file: /cvs/gnome/gdl/scintilla-control/Makefile.am,v
retrieving revision 1.5
diff -u -r1.5 Makefile.am
--- scintilla-control/Makefile.am	2001/07/20 04:35:16	1.5
+++ scintilla-control/Makefile.am	2001/08/05 19:23:53
@@ -7,6 +7,7 @@
 	$(GNOME_CFLAGS) \
 	$(BONOBO_CFLAGS) \
 	$(BONOBOX_CFLAGS) \
+	$(BONOBO_CONF_CFLAGS) \
 	$(VFS_CFLAGS) \
 	$(OAF_CFLAGS)
 
@@ -33,7 +34,9 @@
 	scintilla-editor-gutter.c \
 	scintilla-editor-gutter.h \
 	scintilla-find.c \
-	scintilla-find.h
+	scintilla-find.h \
+	scintilla-property-control.c \
+	scintilla-property-control.h
 
 LEXER_OBJS = \
 	scintilla/LexCPP.o     \
@@ -45,14 +48,15 @@
 	scintilla/LexOthers.o  \
 	scintilla/LexVB.o
 
-scintilla_control_LDADD = \
-	$(GNOME_LIBS)     \
-	$(GNOMEUI_LIBS)   \
-	$(BONOBO_LIBS)    \
-	$(BONOBOX_LIBS)   \
-	$(VFS_LIBS)       \
-	$(LEXER_OBJS)     \
-	../gdl/libgdl.la  \
+scintilla_control_LDADD =   \
+	$(GNOME_LIBS)       \
+	$(GNOMEUI_LIBS)     \
+	$(BONOBO_LIBS)      \
+	$(BONOBOX_LIBS)     \
+	$(BONOBO_CONF_LIBS) \
+	$(VFS_LIBS)         \
+	$(LEXER_OBJS)       \
+	../gdl/libgdl.la    \
         scintilla/libscintilla-widget.a 
 
 test_scintilla_LDADD =  \
@@ -66,6 +70,12 @@
 oaf_in_files=Bonobo_Control_Scintilla.oaf.in
 oaf_DATA = $(oaf_in_files:.oaf.in=.oaf)
 
+schemadir=$(sysconfdir)/gconf/schemas
+schema_DATA=scintilla.schemas
+
 @XML_I18N_MERGE_OAF_RULE@
+
+EXTRA_DIST=$(oaf_in_files) $(oaf_DATA) $(schema_DATA)
 
-EXTRA_DIST=$(oaf_in_files) $(oaf_DATA)
\ No newline at end of file
+install-schemas:
+        GCONF_CONFIG_SOURCE=$(INSTALL_GCONF_CONFIG_SOURCE) $(top_builddir)/gconf/gconftool-$(MAJOR_VERSION) --makefile-install-rule $(srcdir)/$(schema_DATA)
\ No newline at end of file
Index: scintilla-control/scintilla-control.c
===================================================================
RCS file: /cvs/gnome/gdl/scintilla-control/scintilla-control.c,v
retrieving revision 1.13
diff -u -r1.13 scintilla-control.c
--- scintilla-control/scintilla-control.c	2001/07/20 04:35:16	1.13
+++ scintilla-control/scintilla-control.c	2001/08/05 19:23:56
@@ -1,7 +1,5 @@
-/*  -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+/* This file is part of the GNOME Devtool Libraries.
  * 
- * This file is part of the GNOME Devtool Libraries.
- * 
  * Copyright (C) 2000 Dave Camp <dave helixcode com>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -26,6 +24,8 @@
 #include <gtk/gtk.h>
 #include <liboaf/liboaf.h>
 #include <limits.h>
+#include <bonobo-conf/bonobo-config-database.h>
+#include <bonobo-conf/bonobo-config-control.h>
 
 #include "scintilla/Scintilla.h"
 #include "scintilla/ScintillaWidget.h"
@@ -35,6 +35,7 @@
 #include "scintilla-editor-buffer.h"
 #include "scintilla-editor-gutter.h"
 #include "scintilla-find.h"
+#include "scintilla-property-control.h"
 
 #include <gdl/gdl-server-manager.h>
 
@@ -61,6 +62,20 @@
                       CORBA_Environment *ev,
 		      gpointer user_data);
 
+static void config_cb (BonoboListener    *listener,
+		       char              *event_name, 
+		       CORBA_any         *any,
+		       CORBA_Environment *ev,
+		       gpointer           user_data);
+static void config_init (GtkWidget *sci, Bonobo_PropertyBag bag);
+
+static void scintilla_set_linenumbers (GtkWidget *sci, gboolean visible);
+static void scintilla_set_whitespace (GtkWidget *sci, gboolean visible);
+static void scintilla_set_vieweol (GtkWidget *sci, gboolean visible);
+static void scintilla_set_tabwidth (GtkWidget *sci, gint tabwidth);
+static void scintilla_set_usetabchar (GtkWidget *sci, gboolean usetabchar);
+static void scintilla_set_indentationguides (GtkWidget *sci, gboolean visible);
+		    
 static void notify_cb (ScintillaObject *sci, int wparam, void *lparam, 
                        gpointer user_data);
 static void destroy_cb (ScintillaObject *sci, gpointer data);
@@ -91,11 +106,15 @@
     BonoboPropertyBag *pb;
     BonoboPersistFile *file_impl;
     BonoboPersistStream *stream_impl;
+    BonoboPropertyControl *pc_impl;
     ScintillaEditorBuffer *buffer_impl;
     ScintillaEditorGutter *gutter_impl;
+    CORBA_Environment ev;
+    Bonobo_PropertyBag bag;
+    PropertyData *data;
     
     sci = scintilla_new ();
-
+    
     gtk_widget_show_all (GTK_WIDGET (sci));
     
     control = bonobo_control_new (GTK_WIDGET (sci));
@@ -143,29 +162,33 @@
     bonobo_object_add_interface (BONOBO_OBJECT (control),
                                  BONOBO_OBJECT (gutter_impl));
     
+    pc_impl = scintilla_property_control_new (SCINTILLA (sci));
+    bonobo_object_add_interface (BONOBO_OBJECT (control),
+    				 BONOBO_OBJECT (pc_impl));
+    				 
     gtk_signal_connect (GTK_OBJECT (sci), "notify",
                         GTK_SIGNAL_FUNC (notify_cb), NULL);
 
     gtk_signal_connect (GTK_OBJECT (sci), "destroy",
                         GTK_SIGNAL_FUNC (destroy_cb), NULL);
-
-    scintilla_send_message (SCINTILLA(sci), SCI_SETMARGINWIDTHN, 1, 30);
-    scintilla_send_message (SCINTILLA(sci), SCI_SETMARGINTYPEN, 1, SC_MARGIN_NUMBER);
-    scintilla_send_message (SCINTILLA(sci), SCI_SETFOLDFLAGS, 16, 0);
+    
+    CORBA_exception_init (&ev);
+    
+    /* Get a reference to the property bag */
+    bag = bonobo_get_object ("config:/components/scintilla", "Bonobo/PropertyBag", &ev);
+    g_assert (!BONOBO_EX (&ev));
+
+    /* Set event data */
+    data = g_new (PropertyData, 1);
+    data->sci = sci;
+    data->bag = bag;
+	
+    /* Add a listener */
+    bonobo_event_source_client_add_listener (bag, config_cb, NULL, &ev, data);
+    g_assert (!BONOBO_EX (&ev));
     
-    scintilla_send_message (SCINTILLA(sci), SCI_SETPROPERTY, (long)"fold", (long)"1");
-    scintilla_send_message (SCINTILLA(sci), SCI_SETMARGINWIDTHN, 2, 25);
-    scintilla_send_message (SCINTILLA(sci), SCI_SETMARGINTYPEN, 2, SC_MARGIN_SYMBOL);
-    scintilla_send_message (SCINTILLA(sci), SCI_SETMARGINMASKN, 2, SC_MASK_FOLDERS);
-    scintilla_send_message (SCINTILLA (sci), SCI_SETMODEVENTMASK, SC_MOD_CHANGEFOLD, 0);
-    scintilla_send_message (SCINTILLA(sci), SCI_SETMARGINSENSITIVEN, 2, 1);
-    scintilla_send_message (SCINTILLA(sci), SCI_MARKERDEFINE, SC_MARKNUM_FOLDEROPEN, SC_MARK_ARROWDOWN);
-    scintilla_send_message (SCINTILLA(sci), SCI_MARKERSETFORE, SC_MARKNUM_FOLDEROPEN, LONG_MAX);
-    scintilla_send_message (SCINTILLA(sci), SCI_MARKERSETBACK, SC_MARKNUM_FOLDEROPEN, 0);
-    scintilla_send_message (SCINTILLA(sci), SCI_MARKERDEFINE, SC_MARKNUM_FOLDER, SC_MARK_ARROW);
-    scintilla_send_message (SCINTILLA(sci), SCI_MARKERSETFORE, SC_MARKNUM_FOLDER, LONG_MAX);
-    scintilla_send_message (SCINTILLA(sci), SCI_MARKERSETBACK, SC_MARKNUM_FOLDER, 0);
-    scintilla_send_message (SCINTILLA(sci), SCI_SETINDENTATIONGUIDES, 1, 0);
+    /* Load configuration */
+    config_init (sci, bag);
     
     return BONOBO_OBJECT (control);
 }
@@ -283,6 +306,218 @@
 	break;
     }
     }
+}
+
+static void
+config_cb (BonoboListener    *listener,
+	   char              *event_name, 
+	   CORBA_any         *any,
+	   CORBA_Environment *ev,
+	   gpointer           user_data)
+{
+	Bonobo_PropertyBag bag;
+	Bonobo_Property prop;
+	BonoboArg *arg;
+	CORBA_Environment ev;
+	gchar *type;
+	GtkWidget *sci;
+	PropertyData *data;
+	
+	CORBA_exception_init (&ev);
+	
+	data = (PropertyData *) user_data;
+	sci = data->sci;
+	bag = data->bag;
+
+	/* Get event subtype */
+	type = bonobo_event_subtype (event_name);
+	
+	if (!strcmp (type, "line-numbers")) {
+		prop = Bonobo_PropertyBag_getPropertyByName (bag, "line-numbers", &ev);
+		g_assert (!BONOBO_EX (&ev));
+		
+		arg = Bonobo_Property_getValue (prop, &ev);
+		g_assert (!BONOBO_EX (&ev));
+
+		scintilla_set_linenumbers (sci, BONOBO_ARG_GET_BOOLEAN (arg));
+	} else if (!strcmp (type, "whitespace")) {
+		prop = Bonobo_PropertyBag_getPropertyByName (bag, "whitespace", &ev);
+		g_assert (!BONOBO_EX (&ev));
+		
+		arg = Bonobo_Property_getValue (prop, &ev);
+		g_assert (!BONOBO_EX (&ev));
+
+		scintilla_set_whitespace (sci, BONOBO_ARG_GET_BOOLEAN (arg));
+	} else if (!strcmp (type, "vieweol")) {
+		prop = Bonobo_PropertyBag_getPropertyByName (bag, "vieweol", &ev);
+		g_assert (!BONOBO_EX (&ev));
+		
+		arg = Bonobo_Property_getValue (prop, &ev);
+		g_assert (!BONOBO_EX (&ev));
+
+		scintilla_set_vieweol (sci, BONOBO_ARG_GET_BOOLEAN (arg));
+	} else if (!strcmp (type, "tabwidth")) {
+		prop = Bonobo_PropertyBag_getPropertyByName (bag, "tabwidth", &ev);
+		g_assert (!BONOBO_EX (&ev));
+		
+		arg = Bonobo_Property_getValue (prop, &ev);
+		g_assert (!BONOBO_EX (&ev));
+
+		scintilla_set_tabwidth (sci, BONOBO_ARG_GET_INT (arg));
+	} else if (!strcmp (type, "usetabchar")) {
+		prop = Bonobo_PropertyBag_getPropertyByName (bag, "usetabchar", &ev);
+		g_assert (!BONOBO_EX (&ev));
+		
+		arg = Bonobo_Property_getValue (prop, &ev);
+		g_assert (!BONOBO_EX (&ev));
+
+		scintilla_set_usetabchar (sci, BONOBO_ARG_GET_BOOLEAN (arg));
+	} else if (!strcmp (type, "indentationguides")) {
+		prop = Bonobo_PropertyBag_getPropertyByName (bag, "indentationguides", &ev);
+		g_assert (!BONOBO_EX (&ev));
+		
+		arg = Bonobo_Property_getValue (prop, &ev);
+		g_assert (!BONOBO_EX (&ev));
+
+		scintilla_set_indentationguides (sci, BONOBO_ARG_GET_BOOLEAN (arg));
+	}
+}
+
+static void
+config_init (GtkWidget *sci, Bonobo_PropertyBag bag)
+{
+	Bonobo_Property prop;
+	BonoboArg *arg;
+	CORBA_Environment ev;
+	
+	CORBA_exception_init (&ev);
+	
+	/* Set folder properties */
+	scintilla_send_message (SCINTILLA (sci), SCI_SETFOLDFLAGS, 16, 0);
+	scintilla_send_message (SCINTILLA (sci), SCI_SETPROPERTY, (long)"fold", (long)"1");
+	scintilla_send_message (SCINTILLA (sci), SCI_SETMODEVENTMASK, SC_MOD_CHANGEFOLD, 0);
+	
+	/* Define markers */
+	scintilla_send_message (SCINTILLA (sci), SCI_MARKERDEFINE, SC_MARKNUM_FOLDEROPEN, SC_MARK_ARROWDOWN);
+	scintilla_send_message (SCINTILLA (sci), SCI_MARKERSETFORE, SC_MARKNUM_FOLDEROPEN, LONG_MAX);
+	scintilla_send_message (SCINTILLA (sci), SCI_MARKERSETBACK, SC_MARKNUM_FOLDEROPEN, 0);
+	scintilla_send_message (SCINTILLA (sci), SCI_MARKERDEFINE, SC_MARKNUM_FOLDER, SC_MARK_ARROW);
+	scintilla_send_message (SCINTILLA (sci), SCI_MARKERSETFORE, SC_MARKNUM_FOLDER, LONG_MAX);
+	scintilla_send_message (SCINTILLA (sci), SCI_MARKERSETBACK, SC_MARKNUM_FOLDER, 0);
+	scintilla_send_message (SCINTILLA (sci), SCI_SETINDENTATIONGUIDES, 1, 0);
+	
+	/* Set line-numbers property */
+	prop = Bonobo_PropertyBag_getPropertyByName (bag, "line-numbers", &ev);
+	g_assert (!BONOBO_EX (&ev));
+		
+	arg = Bonobo_Property_getValue (prop, &ev);
+	g_assert (!BONOBO_EX (&ev));
+
+	scintilla_set_linenumbers (sci, BONOBO_ARG_GET_BOOLEAN (arg));
+	
+	/* Set whitespace property */
+	prop = Bonobo_PropertyBag_getPropertyByName (bag, "whitespace", &ev);
+	g_assert (!BONOBO_EX (&ev));
+		
+	arg = Bonobo_Property_getValue (prop, &ev);
+	g_assert (!BONOBO_EX (&ev));
+	
+	scintilla_set_whitespace (sci, BONOBO_ARG_GET_BOOLEAN (arg));
+	
+	/* Set vieweol property */
+	prop = Bonobo_PropertyBag_getPropertyByName (bag, "vieweol", &ev);
+	g_assert (!BONOBO_EX (&ev));
+		
+	arg = Bonobo_Property_getValue (prop, &ev);
+	g_assert (!BONOBO_EX (&ev));
+	
+	scintilla_set_vieweol (sci, BONOBO_ARG_GET_BOOLEAN (arg));
+	
+	/* Set tabwidth property */
+	prop = Bonobo_PropertyBag_getPropertyByName (bag, "tabwidth", &ev);
+	g_assert (!BONOBO_EX (&ev));
+		
+	arg = Bonobo_Property_getValue (prop, &ev);
+	g_assert (!BONOBO_EX (&ev));
+	
+	scintilla_set_tabwidth (sci, BONOBO_ARG_GET_INT (arg));
+	
+	/* Set usetabchar property */
+	prop = Bonobo_PropertyBag_getPropertyByName (bag, "usetabchar", &ev);
+	g_assert (!BONOBO_EX (&ev));
+
+	arg = Bonobo_Property_getValue (prop, &ev);
+	g_assert (!BONOBO_EX (&ev));
+	
+	scintilla_set_usetabchar (sci, BONOBO_ARG_GET_BOOLEAN (arg));
+	
+	/* Set indentationguides property */
+	prop = Bonobo_PropertyBag_getPropertyByName (bag, "indentationguides", &ev);
+	g_assert (!BONOBO_EX (&ev));
+		
+	arg = Bonobo_Property_getValue (prop, &ev);
+	g_assert (!BONOBO_EX (&ev));
+	
+	scintilla_set_indentationguides (sci, BONOBO_ARG_GET_BOOLEAN (arg));
+}
+
+static void
+scintilla_set_linenumbers (GtkWidget *sci, gboolean visible)
+{
+	g_assert (sci != NULL);
+	g_assert (IS_SCINTILLA (sci));
+	if (visible) {
+		scintilla_send_message (SCINTILLA (sci), SCI_SETMARGINWIDTHN, 1, 30);
+		scintilla_send_message (SCINTILLA (sci), SCI_SETMARGINTYPEN, 1, SC_MARGIN_NUMBER);
+		scintilla_send_message (SCINTILLA (sci), SCI_SETMARGINMASKN, 1, 0);
+		scintilla_send_message (SCINTILLA (sci), SCI_SETMARGINSENSITIVEN, 1, 0);			
+    
+		scintilla_send_message (SCINTILLA (sci), SCI_SETMARGINWIDTHN, 2, 25);
+		scintilla_send_message (SCINTILLA (sci), SCI_SETMARGINTYPEN, 2, SC_MARGIN_SYMBOL);
+		scintilla_send_message (SCINTILLA (sci), SCI_SETMARGINMASKN, 2, SC_MASK_FOLDERS);
+		scintilla_send_message (SCINTILLA (sci), SCI_SETMARGINSENSITIVEN, 2, 1);
+	} else {
+		scintilla_send_message (SCINTILLA (sci), SCI_SETMARGINWIDTHN, 1, 25);
+		scintilla_send_message (SCINTILLA (sci), SCI_SETMARGINTYPEN, 1, SC_MARGIN_SYMBOL);
+		scintilla_send_message (SCINTILLA (sci), SCI_SETMARGINMASKN, 1, SC_MASK_FOLDERS);
+		scintilla_send_message (SCINTILLA (sci), SCI_SETMARGINSENSITIVEN, 1, 1);
+		
+		scintilla_send_message (SCINTILLA (sci), SCI_SETMARGINWIDTHN, 2, 0);
+	}
+}
+
+static void
+scintilla_set_whitespace (GtkWidget *sci, gboolean visible)
+{
+	if (visible) {
+		scintilla_send_message (SCINTILLA (sci), SCI_SETVIEWWS, SCWS_VISIBLEALWAYS, 0);
+	} else {
+		scintilla_send_message (SCINTILLA (sci), SCI_SETVIEWWS, SCWS_INVISIBLE, 0);
+	}
+}
+
+static void
+scintilla_set_vieweol (GtkWidget *sci, gboolean visible)
+{
+	scintilla_send_message (SCINTILLA (sci), SCI_SETVIEWEOL, visible, 0);
+}
+
+static void 
+scintilla_set_tabwidth (GtkWidget *sci, gint tabwidth)
+{
+	scintilla_send_message (SCINTILLA (sci), SCI_SETTABWIDTH, tabwidth, 0);
+}
+
+static void 
+scintilla_set_usetabchar (GtkWidget *sci, gboolean usetabchar)
+{
+	scintilla_send_message (SCINTILLA (sci), SCI_SETUSETABS, usetabchar, 0);
+}
+
+static void 
+scintilla_set_indentationguides (GtkWidget *sci, gboolean visible)
+{
+	scintilla_send_message (SCINTILLA (sci), SCI_SETINDENTATIONGUIDES, visible, 0);
 }
 
 /*


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