bonobo-conf patch for gdl & gIDE
- From: Jeroen Zwartepoorte <Jeroen xs4all nl>
- To: gnome-devtools gnome org
- Subject: bonobo-conf patch for gdl & gIDE
- Date: 01 Aug 2001 20:10:06 +0200
Hi all,
Here is the working version of the bonobo-conf patch for gdl & gIDE.
This patch requires bonobo-conf-0.10. Previous versions will NOT work
since there is a bug in the event callback mechanism.
ftp://ftp.gnome.org/pub/GNOME/unstable/sources/bonobo-conf/bonobo-conf-0.10.tar.gz
IIRC, to build bonobo-conf-0.10 you also need libtool 1.4:
ftp://ftp.gnu.org/gnu/libtool/libtool-1.4.tar.gz
This patch adds bonobo-conf support to the scintilla widget in gdl and
implements the Settings menuitem in gIDE. gIDE will query the current
editor widget for a PropertyControl interface. scintilla implements this
interface and provides a GUI via that interface for changing the
line-numbers property. In the settings dialog, you can see a single
property for showing/hiding the line-numbers in the scintilla widget.
There still needs to be some work done on the scintilla portion of this
patch: currently, it doesn't load the settings on startup, so initially,
the line-numbers are ALWAYS visible. I'll try and fix this asap.
Also, the cleanup code might not be 100% (variables do nog get freed in
some places i think).
Jeroen
/* 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);
}
static void
property_change_cb (BonoboListener *listener,
char *event_name,
CORBA_any *any,
CORBA_Environment *ev,
gpointer user_data)
{
gchar *type;
PropertyData *data;
GtkWidget *sci;
CORBA_Environment ev;
Bonobo_PropertyBag bag;
Bonobo_Property prop;
BonoboArg *arg;
CORBA_exception_init (&ev);
printf ("received event %s\n", event_name);
type = bonobo_event_subtype (event_name);
data = (PropertyData *) user_data;
sci = data->sci;
bag = data->bag;
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));
if ( BONOBO_ARG_GET_BOOLEAN (arg)) {
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);
}
}
}
BonoboControl *
get_impl (BonoboPropertyControl *control,
int page_number,
void *closure)
{
GtkWidget *w, *box;
GtkObject *o;
CORBA_Environment ev;
Bonobo_PropertyBag bag;
BonoboControl *ctrl;
PropertyData *data;
static const gchar *name = "Scintilla";
CORBA_exception_init (&ev);
/* Get a reference to the property bag */
bag = bonobo_get_object ("config:/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 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);
gtk_widget_show_all (box);
/* Set event data */
data = g_new (PropertyData, 1);
data->sci = GTK_WIDGET (closure);
data->bag = bag;
/* Add a listener */
bonobo_event_source_client_add_listener (bag, property_change_cb,
NULL, &ev, data);
g_assert (!BONOBO_EX (&ev));
/* 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_return_val_if_fail (IS_SCINTILLA (sci), NULL);
printf ("creating property control\n");
return bonobo_property_control_new (get_impl, 1, sci);
}
/* 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
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/01 18:03:51
@@ -1,3 +1,11 @@
+2001-08-01 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
+
+ * configure.in: Added bonobo-conf 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/01 18:03:52
@@ -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/01 18:03:54
@@ -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/01 18:03:58
@@ -26,6 +26,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 +37,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>
@@ -91,9 +94,10 @@
BonoboPropertyBag *pb;
BonoboPersistFile *file_impl;
BonoboPersistStream *stream_impl;
+ BonoboPropertyControl *pc_impl;
ScintillaEditorBuffer *buffer_impl;
ScintillaEditorGutter *gutter_impl;
-
+
sci = scintilla_new ();
gtk_widget_show_all (GTK_WIDGET (sci));
@@ -143,6 +147,10 @@
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);
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/01 18:00:10
@@ -1,3 +1,9 @@
+2001-08-01 Jeroen Zwartepoorte <Jeroen xs4all nl>
+ * src/gI_window.c (settings_cmd): Added bonobo-conf (PropertyControl
+ interface) support and implemented Settings menuitem
+
+ * configure.in: Added bonobo-conf 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/01 18:00:11
@@ -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/01 18:00:25
@@ -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,54 @@
gdk_window_raise (GTK_WIDGET (about)->window);
}
+static void
+settings_cmd (GtkWidget *w, GideWindow *window)
+{
+ GNOME_Development_Environment_Document doc;
+ char *moniker;
+ Bonobo_Control control;
+ CORBA_Environment ev;
+ Bonobo_PropertyControl pc;
+ GtkWidget *prefs;
+ 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));
+
+ /* Create preferences widget & show */
+ prefs = bonobo_preferences_new (pc);
+ gtk_widget_show_all (prefs);
+}
+
/* 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),
#endif
+ BONOBO_UI_UNSAFE_VERB ("SettingsSettings", settings_cmd),
BONOBO_UI_UNSAFE_VERB ("HelpAbout", about_cmd),
BONOBO_UI_VERB_END
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]