scintilla configuration patch



Hi all,

Here are the much improved versions of the bonobo-conf patches for gdl &
gIDE. These patches add a "Editor settings..." command to gIDE. This
command will query the current editor component for a PropertyControl
interface and show a preferences dialog based on that.

Since we can probably fill at least 3 tabs with scintilla settings, i've
created a separate command for the editor settings. The editor component
also doesn't need to register itself with the shell, like the plugins
need to do (plugins need to register with the shell and indicate that
they implement the PropertyControl interface so gIDE can query for
that).

These patches are not bug free. There is a weird bug in there somewhere
that causes a segfault in the scintilla-control. I haven't been able to
find the cause but i'm hoping you guys can help me with that.

I haven't been able to figure out how to get configure & make to install
the scintilla.schemas automatically. You'll have to do this manually for
now: gconftool --instal-schema-file=scintilla.schemas
scintilla.schemas resides in the gdl/scintilla-control dir.


Jeroen
<gconfschemafile>
  <schemalist>
    <schema>
      <key>/schemas/components/scintilla/line-numbers</key>
      <applyto>/components/scintilla/line-numbers</applyto>
      <owner>scintilla</owner>
      <type>bool</type>
      <locale name="en">
        <default>true</default>
        <short>show line numbers</short>
        <long>show line numbers in a margin on the left side of the component</long>
      </locale>
    </schema>
    <schema>
      <key>/schemas/components/scintilla/whitespace</key>
      <applyto>/components/scintilla/whitespace</applyto>
      <owner>scintilla</owner>
      <type>bool</type>
      <locale name="en">
        <default>false</default>
        <short>show whitespace</short>
        <long>show whitespace using arrows for tabs and dots for spaces</long>
      </locale>
    </schema>
    <schema>
      <key>/schemas/components/scintilla/vieweol</key>
      <applyto>/components/scintilla/vieweol</applyto>
      <owner>scintilla</owner>
      <type>bool</type>
      <locale name="en">
        <default>false</default>
        <short>show end of line</short>
        <long>show end of lines, marked with the type of line terminator</long>
      </locale>
    </schema>
    <schema>
      <key>/schemas/components/scintilla/tabwidth</key>
      <applyto>/components/scintilla/tabwidth</applyto>
      <owner>scintilla</owner>
      <type>int</type>
      <locale name="en">
        <default>8</default>
        <short>tab width</short>
        <long>the amount of spaces shown for a tab character</long>
      </locale>
    </schema>
    <schema>
      <key>/schemas/components/scintilla/usetabchar</key>
      <applyto>/components/scintilla/usetabchar</applyto>
      <owner>scintilla</owner>
      <type>bool</type>
      <locale name="en">
        <default>true</default>
        <short>use tab character</short>
        <long>insert a tab character ('\t') when the user presses the tab key</long>
      </locale>
    </schema>
    <schema>
      <key>/schemas/components/scintilla/indentationguides</key>
      <applyto>/components/scintilla/indentationguides</applyto>
      <owner>scintilla</owner>
      <type>bool</type>
      <locale name="en">
        <default>true</default>
        <short>show indentation guides</short>
        <long>show the amount of indentation by drawing a vertical line for every indentation level</long>
      </locale>
    </schema>
  </schemalist>
</gconfschemafile>




/* 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
 * 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 __SCINTILLA_PROPERTY_CONFIG_FILE__
#define __SCINTILLA_PROPERTY_CONFIG_FILE__

BonoboPropertyControl *scintilla_property_control_new (GtkWidget *sci);

typedef struct 
{
	GtkWidget *sci;
	Bonobo_PropertyBag *bag;
} PropertyData;

#endif
/* 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
 * 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.  
 */

#include <config.h>
#include <gtk/gtk.h>
#include <gnome.h>
#include <bonobo.h>
#include <bonobo-conf/bonobo-config-control.h>
#include <bonobo-conf/bonobo-property-editor.h>

#include "scintilla/Scintilla.h"
#include "scintilla/ScintillaWidget.h"
#include "scintilla-property-control.h"

static void 
get_title (BonoboPropertyBag *bag,
	   BonoboArg *arg,
	   guint arg_id,
           CORBA_Environment *ev,
	   gpointer user_data)
{
	if (arg_id == 0 && arg->_type == BONOBO_ARG_STRING)
 		BONOBO_ARG_SET_STRING (arg, (char *)user_data);
}

BonoboControl *
get_impl (BonoboPropertyControl *control,
	  int page_number,
	  void *closure)
{
	GtkWidget *w, *box;
	GtkObject *o;
	CORBA_Environment ev;
	Bonobo_PropertyBag bag;
	BonoboControl *ctrl;
	static const gchar *name = "Scintilla";
	
	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));
	
	/* Create vertical box */
	box = gtk_vbox_new (FALSE, 5);
	gtk_container_set_border_width (GTK_CONTAINER (box), 5);
	
	/* Create line-numbers boolean property editor */
	o = bonobo_peditor_boolean_new (_("Show line numbers"));
	bonobo_peditor_set_property (BONOBO_PEDITOR (o), bag, "line-numbers", 
				     TC_boolean, NULL);
	w = bonobo_peditor_get_widget (BONOBO_PEDITOR (o));
	gtk_container_add (GTK_CONTAINER (box), w);
	
	/* Create whitespace boolean property editor */
	o = bonobo_peditor_boolean_new (_("Show whitespace"));
	bonobo_peditor_set_property (BONOBO_PEDITOR (o), bag, "whitespace", 
				     TC_boolean, NULL);
	w = bonobo_peditor_get_widget (BONOBO_PEDITOR (o));
	gtk_container_add (GTK_CONTAINER (box), w);

	/* Create vieweol boolean property editor */	
	o = bonobo_peditor_boolean_new (_("Show End of Line"));
	bonobo_peditor_set_property (BONOBO_PEDITOR (o), bag, "vieweol", 
				     TC_boolean, NULL);
	w = bonobo_peditor_get_widget (BONOBO_PEDITOR (o));
	gtk_container_add (GTK_CONTAINER (box), w);
	
	/* Create tabwidth int range property editor */
	o = bonobo_peditor_int_range_new (0, 100, 1);
	bonobo_peditor_set_property (BONOBO_PEDITOR (o), bag, "tabwidth", 
				     TC_long, NULL);
	w = bonobo_peditor_get_widget (BONOBO_PEDITOR (o));
	bonobo_peditor_set_guard (w, bag, "usetabchar");	
	gtk_container_add (GTK_CONTAINER (box), w);
	
	/* Create usetabchar boolean property editor */	
	o = bonobo_peditor_boolean_new (_("Use tab character"));
	bonobo_peditor_set_property (BONOBO_PEDITOR (o), bag, "usetabchar", 
				     TC_boolean, NULL);
	w = bonobo_peditor_get_widget (BONOBO_PEDITOR (o));
	gtk_container_add (GTK_CONTAINER (box), w);
	
	gtk_widget_show_all (box);
	
	/* Create new BonoboControl */
	ctrl =  bonobo_control_new (box);
	g_assert (ctrl != NULL);
	
	/* Set title property */
	bag = bonobo_property_bag_new (get_title, NULL, name);
	
	bonobo_property_bag_add (bag, "bonobo:title", 0, 
				 BONOBO_ARG_STRING, NULL, NULL, 
				 BONOBO_PROPERTY_READABLE);

	bonobo_object_add_interface (BONOBO_OBJECT (ctrl),
				     BONOBO_OBJECT (bag));	
	
	return ctrl;
}

BonoboPropertyControl *
scintilla_property_control_new (GtkWidget *sci)
{
	g_assert (sci != NULL);
	g_return_val_if_fail (IS_SCINTILLA (sci), NULL);
	printf ("creating property control\n");
	return bonobo_property_control_new (get_impl, 1, sci);
}
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 18:09:12
@@ -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 18:09:13
@@ -107,8 +107,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 +119,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 18:09:13
@@ -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 =  \
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 18:09:17
@@ -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);
 }
 
 /*
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gIDE/ChangeLog,v
retrieving revision 1.126
diff -u -r1.126 ChangeLog
--- ChangeLog	2001/07/22 18:09:24	1.126
+++ ChangeLog	2001/08/05 18:10:44
@@ -1,3 +1,10 @@
+2001-08-05  Jeroen Zwartepoorte <Jeroen xs4all nl>
+	* src/gI_window.c (settings_editor_cmd): Added bonobo-conf 
+	(PropertyControl interface) support and implemented Editor 
+	settings command
+	
+	* configure.in: Added bonobo-conf-0.10 dependency
+
 2001-07-22  JP Rosevear  <jpr ximian com>
 
 	* Make sure oaf.in files are disted
Index: configure.in
===================================================================
RCS file: /cvs/gnome/gIDE/configure.in,v
retrieving revision 1.46
diff -u -r1.46 configure.in
--- configure.in	2001/07/22 18:09:24	1.46
+++ configure.in	2001/08/05 18:10:44
@@ -53,6 +53,7 @@
 GDL_CHECK_LIB(gnome-libs, gnome, 1.2.9)
 GDL_CHECK_LIB(bonobo, bonobo, 1.0.7)
 GDL_CHECK_LIB(bonobox, bonobox, 1.0.7)
+GDL_CHECK_LIB(bonobo-conf, bonobo_conf, 0.10)
 GDL_CHECK_LIB(oaf, oaf, 0.6.5)
 GDL_CHECK_LIB(libglade, libglade)
 GDL_CHECK_LIB(glade, gal, 0.8.0)
@@ -62,8 +63,8 @@
 GDL_CHECK_LIB(gnome-debug, gdf, 0.1.6)
 
 dnl Extra stuff
-EXTRA_GNOME_LIBS=`gnome-config --libs bonobox libglade print gdf gnome_build gal gdl vfs`
-EXTRA_GNOME_CFLAGS=`gnome-config --cflags bonobox libglade print gdf gnome_build gal gdl vfs`
+EXTRA_GNOME_LIBS=`gnome-config --libs bonobox bonobo_conf libglade print gdf gnome_build gal gdl vfs`
+EXTRA_GNOME_CFLAGS=`gnome-config --cflags bonobox bonobo_conf libglade print gdf gnome_build gal gdl vfs`
 
 IDL_CFLAGS=`gnome-config --cflags idl`
 AC_SUBST(IDL_CFLAGS)
Index: src/gI_window.c
===================================================================
RCS file: /cvs/gnome/gIDE/src/gI_window.c,v
retrieving revision 1.37
diff -u -r1.37 gI_window.c
--- src/gI_window.c	2001/07/20 04:23:21	1.37
+++ src/gI_window.c	2001/08/05 18:10:50
@@ -21,10 +21,12 @@
 #include <liboaf/liboaf.h>
 #include <bonobo/bonobo-ui-util.h>
 #include <bonobo/bonobo-listener.h>
+#include <bonobo-conf/bonobo-preferences.h>
 #include <gal/e-paned/e-paned.h>
 #include <gal/e-paned/e-vpaned.h>
 #include <gal/e-paned/e-hpaned.h>
 #include "gI_window.h"
+#include "shell.h"
 
 #include <libgide/libgide.h>
 
@@ -69,13 +71,62 @@
 		gdk_window_raise (GTK_WIDGET (about)->window);
 }
 
+static void
+settings_editor_cmd (GtkWidget *w, GideWindow *window)
+{
+	GNOME_Development_Environment_Document doc;
+	char *moniker;
+	Bonobo_Control control;
+	CORBA_Environment ev;
+	Bonobo_PropertyControl pc;
+	GtkWidget *dialog;
+	GideShell *shell;
+	
+	CORBA_exception_init (&ev);
+
+	/* Get GideShell instance for this window */
+	shell = GIDE_SHELL (gtk_object_get_data (GTK_OBJECT (window), "GideShell"));
+	
+	/* Create moniker for current document */
+	moniker = g_strdup_printf ("gide:%s!CurrentDocument", shell->id);
+
+	/* Get Document instance */	
+	doc = bonobo_get_object (moniker, "IDL:GNOME/Development/Environment/Document:1.0", &ev);
+	g_assert (!BONOBO_EX (&ev));
+
+	g_free (moniker);
+
+	/* Get editor control */	
+	control = GNOME_Development_Environment_Document_getEditor (doc, &ev);
+	g_assert (!BONOBO_EX (&ev));
+	
+	bonobo_object_release_unref (doc, &ev);
+	g_assert (!BONOBO_EX (&ev));
+	
+	/* Query PropertyControl interface */
+	pc = Bonobo_Unknown_queryInterface (control, "IDL:Bonobo/PropertyControl:1.0", &ev);
+	g_assert (!BONOBO_EX (&ev));
+	
+	if (pc != CORBA_OBJECT_NIL) {
+		/* Create preferences widget & show */
+		dialog = bonobo_preferences_new (pc);	
+		gtk_widget_show_all (dialog);
+	} else {		
+		dialog = gnome_message_box_new (_("Editor component does not support PropertyControl interface"), 
+						GNOME_MESSAGE_BOX_INFO, 
+						GNOME_STOCK_BUTTON_OK, NULL);
+		gtk_widget_show (dialog);
+	}	
+}
+
 /* Menu verbs */
 static BonoboUIVerb verbs [] = {
 	BONOBO_UI_UNSAFE_VERB ("FileExit", tmp_exit),
 #if 0
 	BONOBO_UI_UNSAFE_VERB ("ToolsPlugins", dialog_plugin_manager),
-	BONOBO_UI_UNSAFE_VERB ("SettingsSettings", dialog_prefs_cb),
+	BONOBO_UI_UNSAFE_VERB ("SettingsSettings", settings_cmd),
 #endif
+	BONOBO_UI_UNSAFE_VERB ("SettingsEditor", settings_editor_cmd),
 	BONOBO_UI_UNSAFE_VERB ("HelpAbout", about_cmd),
 	
 	BONOBO_UI_VERB_END
Index: src/gide.xml
===================================================================
RCS file: /cvs/gnome/gIDE/src/gide.xml,v
retrieving revision 1.5
diff -u -r1.5 gide.xml
--- src/gide.xml	2001/07/20 04:08:53	1.5
+++ src/gide.xml	2001/08/05 18:10:50
@@ -7,6 +7,9 @@
 
 		<cmd name="SettingsSettings" _label="_Settings..."
                 _tip="Set application preferences" pixtype="stock" pixname="Preferences"/>
+                
+                <cmd name="SettingsEditor" _label="_Editor settings..."
+                _tip="Set editor preferences" pixtype="stock" pixname="Preferences"/>                
 
 		<cmd name="ToolsPlugins" _label="Plug-ins..." 
                 _tip="Manage available plugin modules"/>
@@ -52,6 +55,8 @@
 		<submenu name="Settings" _label="_Settings">
 
 			<menuitem name="SettingsSettings" verb=""/>
+			
+			<menuitem name="SettingsEditor" verb=""/>
 
                         <menuitem name="BonoboCustomize" verb="" _label="Customi_ze..." pos="bottom"/>
 		</submenu>
@@ -70,6 +75,8 @@
 		<placeholder name="DocumentOps"/>
 
 		<toolitem name="SettingsSettings" verb=""/>
+		
+		<toolitem name="SettingsEditor" verb=""/>
 
 		<toolitem name="FileExit" verb=""/>
 


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