GNOME Bugzilla – Bug 346896
Use GtkSourceView for python code.
Last modified: 2006-10-19 09:51:42 UTC
In the calculated fields and buttons scripts windows, we should use GtkSourceView to have syntax highlighting.
Created attachment 68567 [details] [review] glom_sourceview.patch This patch does most of it, though the syntax-highlighting doesn't seem to work yet. Maybe I got the mime-type wrong.
I adapted the patch to Glom and GtkSourceViewmm HEAD but I encountered the following problem where I am not sure how to solve it: (:13456): libglademm-CRITICAL **: widget `textview_calculation' (in glade file `/usr/share/glom/glade//glom.glade') is of type `gtkmm__GtkTextView' but `GtkSourceView' was expected ** (:13456): CRITICAL **: Gnome::Glade::Xml::get_widget(): dynamic_cast<> failed. Segmentation fault Of course in the glade file textview_calculation has class=GtkSourceView and I also checked gtksourceviewmm::SourceView::get_type() in a sample application with gives gtkmm_GtkSourceView correctly. Maybe libglademm is messing things up here, but I will try to investigate this.
Obviously I did not check the glade file carefully enough because I just looked at the wrong place and could fix it easily by replacing class=GtkTextView there. Anyway, to get hightlighting to work I have to call Sourceview::get_source_buffer() which seems not to work so I first have to fix it in gtksourceviewmm.
Hello, I have just commited the changeset #14 to gtksourceview trunk that may fix your problem. Just let me know. Cheers, Dodji.
Hi! Sorry, that did not help, I still end up with this when calling m_text_view->get_source_buffer()! If you like I can post the updated patch here though it is still incomplete and does not work because of the bug above. Johannes
Forgot to paste the error message: (:4734): GLib-GObject-WARNING **: invalid cast from `GtkTextBuffer' to `GtkSourceBuffer'
Okay, let me try something else. I will let you know when I have something that works.
Created attachment 72368 [details] [review] Patch to support syntax highlighting for python It was definitly not a fault of gtksourceviewmm but rather a problem of libglade which does simply not know about gtksourceviewmm. To make it working gtksourceview mm would have to depend on Gnome which is not good so I created a work-around. Attached is a patch which makes it working in the dialogs I could reach and also in those I did find in the sources but could not reach them in the UI, so it would be nice if someone could test it. Thanks to Openismus for paying the work on this patch!
We'll use this when Glom branches for 1.2.
Firstly, sorry that my patch used API changes that I had not yet committe to gtksourceviewmm. That's done now. This patch works. The main things were 1. libglade seems to set a TextBuffer in the GtkSourceView, instead of using its default SourceBuffer. 2. We need to call set_highlight().
I'll upload the working patch later.
Created attachment 72943 [details] [review] glom_sourceview2.patch
Committed to HEAD. Thanks.