gedit ported to gio/gvfs
In the last months I’ve been pretty busy and time for gedit, gtksourceview and GNOME in general has been particularly small. The lack of posts on this page pretty much reflects that.
When reading discussions about decadence I could not help but feel a bit guilty, especially since gedit user base has never been more healthy: new plugins are released, users partecipate on irc and mailing lists, blog posts about customizing gedit pop up daily on the interweb.
It seemed inevitable that gedit 2.24 would have been pretty much exactly the same as 2.22, but Jesse came to rescue. He first ported the filebrowser side pane to gio and last week he completed the work by also reworking all the gedit internals (especially remote file loading and saving) to use gio instead of gnome-vfs. As of today I committed that work to svn and I will try to make a tarball release as soon as possible.
Since Jesse was on a roll, he also ported all the dialogs from libglade to gtkbuilder, killing yet another dependency.
Please test it, test it, test it and test it again and then report bugs!
better late than never
We finally released a new developement version of gedit that reimplements printing using GTK+ print support. It also includes a custom print preview widget so that we can keep our current UI (print preview embedded in a tab). This means that we do not depend on libgnomeprint and libgnomeprintui anymore… it was about time!
Please test it, test it, test it and report any regression or problem!
GtkSourceView 2.1
Today we released GtkSourceView 2.1, the developement release for 2.2 that will be part of the next GNOME. In this cycle we didn’t have much time to work on it, however over the Christmas break we reimplemented two important features that went missing in the big 2.0 release:
This means that we have reached feature parity with the old GtkSourceView 1.
The API however is different from what was there in gtksourceview 1: in particular printing now integrates with GtkPrint instead of using the old and deprecated gnome-print libraries. GtkPrint is a pretty strange beast (due to the fact that a cross platform printing api is quite challenging), but in the end I think we found a pretty elegant API.
We expose a GtkSourcePrintCompositor class that knows how to draw the text view (including syntax highlighting, line numbers, header and footer): when running a GtkPrintOperation to print, you just need to instanciate a compositor for the current text buffer and delegate to it all the pagination and drawing. Pagination, which for long documents can take quite a bit of time, is async which allows to present a progress bar without blocking the UI.
Here is a simple example showing how to use the new printing API:
static gboolean
paginate (GtkPrintOperation *operation,
GtkPrintContext *context,
GtkSourcePrintCompositor *compositor)
{
if (gtk_source_print_compositor_paginate (compositor, context))
{
gint n_pages;
n_pages = gtk_source_print_compositor_get_n_pages (compositor);
gtk_print_operation_set_n_pages (operation, n_pages);
return TRUE;
}
return FALSE;
}
draw_page (GtkPrintOperation *operation,
GtkPrintContext *context,
gint page_nr,
GtkSourcePrintCompositor *compositor)
{
gtk_source_print_compositor_draw_page (compositor, context, page_nr);
}
static void
end_print (GtkPrintOperation *operation,
GtkPrintContext *context,
GtkSourcePrintCompositor *compositor)
{
g_object_unref (compositor);
}
static void
print_source_view (GtkSourceView *view)
{
GtkSourcePrintCompositor *compositor;
GtkPrintOperation *operation;
compositor = gtk_source_print_compositor_new_from_view (view);
operation = gtk_print_operation_new ();
g_signal_connect (operation, "paginate", G_CALLBACK (paginate), compositor);
g_signal_connect (operation, "draw-page", G_CALLBACK (draw_page), compositor);
g_signal_connect (operation, "end-print", G_CALLBACK (end_print), compositor);
gtk_print_operation_run (operation,
GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
NULL, NULL);
g_object_unref (operation);
}
Bits & Pieces
Last period was fairly busy and I didn’t get much time to hack on gnome related stuff… I hope to be able to catch up a bit in the next weeks, especially to take care of some great patches that are waiting in bugzilla. <h3>GNOME Talk @ IBM Technical Conference</h3>
Thanks to Fabio Marzocca I was approached by IBM to give a talk about GNOME and ubuntu at a linux technical conference held at their IBM Forum in Segrate. Despite the fact I am not an experienced presenter the talk went farly well, slides are available here. At the meeting I also had the chance to meet Alessandro Rubini of Linux Device Drivers fame. <h3>Google GHOP GtkSourceView themes</h3>
One of the tasks accepted for the Google GHOP program was writing five color schemes for gtksourceview. Will Farrington claimed the task and today delivered five good looking themes. Well done Will!
Check them out at on the wiki page.
I especially like Cobalt, so here is a screenie.
Speaking of Google, this week I also received a Google SoC t-shirt. Thanks Google! <h3>gedit without libgnome</h3>
MIkael Hermansson filed a patch in bugzilla to conditionally disable the libgnome dependency of gedit. As mentioned before I really look forward to disabling libgnome uncoditioally and this is definitely a step in the right direction as we work through the remaining issues.
Delivering the killing blow to libgnome
Getting rid of the libgnome[ui] dependency and of all the legacy stuff that it brings in has been a work in progress for many gnome applications. While replacing some old cruft has been very easy as soon as a proper replacement was put into GTK+ itself, there are a bunch of things for which figuring out what to do is not so clear… Now that we are at the start of the 2.22 cycle I’d like to get some feedback on the status of these things.
As you can probably guess I’ll take gedit as a case, but I think it is pretty much the same for many other applications. In order of importance, libgnome is still needed for:
Unless I am missing some other magic feature that gnome-program provides, that is everything that libgnome[ui] is needed for (I am intentionally leaving out migration from gnome-print to gtk print stuff and from gnome-vfs to gvfs, since they are separate issues).
Will we manage to put the nails in libgnome’s coffin for 2.22?
GtkSourceView 2 API frozen
With yesterday night release of GtkSourceView 1.90.5 (which will likely become 2.0 next week) we consider the API frozen and in the future releases only API additions will happen.
Honestly we hoped to have more early adopters so that we could have more feedback on the API changes, but I can understand how painful it is to track a library that it is a bit of a moving target :)
Anyway, now it’s a good time to start porting your app to GtkSourceView 2 and an even better time to bind it to your favourite language (Python bindings are already available). Why? Because you get a way more accurate syntax highlighting and because you get support for style schemes.
I will not go into the details of the API changes (most of it should be straightforward), my advice is just to be careful with the memory management of the LanguageManager and StyleSchemeManager: unless you want to do advanced stuff like a style scheme editor or use two separate highlighting contexts in the same app, you should probably stick to the singletons provided by GtkSourceView itself.
That said, I should also point out that there are a few feature regressions with respect to GtkSourceView 1 and anyone getting ready to port his app should be aware of that:
We are more than willing to reintroduce these features back in 2.2 (though printing is a bit of a gray area since bits of it really belong to gtk itself), but we need feedback from the apps using the library to get the API right!
gedit style schemes
Yesterday night I released new developement versions of GtkSourceView, PyGtkSourceView and gedit. With this release of gedit one of the more important features of gtksourceview 2 will be visible: style schemes support.
As you can see from the screenshot the old Syntax Highlighting preferences and the color buttons to set text and background colors are gone, replaced by the selection of the style scheme. A style scheme takes care of all of the syntax highlighting colors and also allows to set some more customizations (for instance the current line highlighting color). The plan was to have a simple style scheme editor to create and tweak style schemes from the GUI, but at this point it looks unlikely for 2.20, also because figuring out the proper UI is not as trivial as one may first think. If the lack of a GUI to edit colors really bothers you, feedback is welcome, especially with patches attached :)
At least I’ll try to add buttons to install and remove schemes from file in the hope that a good collection of third party schemes will be soon available. By the way, if any of the Gnome Online people want to give it a try at creating a service to install Style Schemes from an online collection I surely will not oppose.
Creating a style scheme is very simple: just create yourtheme.xml and drop it in ~/.local/share/gtksourceview-2.0/styles.
The file format is very simple, as you can see from this quick example I put together, a lowcontrast dark style with tango colors: darktango.xml
It is basically a list of:
<style name="element" foreground="color" background="color"/>
Where element can be one of the builtin elements (like “text” or “bracket-match”) or a syntax element specified in the form “language_id:element_id” and color can be either specified directly as #NNNNN or defined in a palette.
“def:element_id” stands for the default style for those kind of elements, since GtkSourceView tries to map the styles to reasonable defaults. Let’s make an example: if I write “while” in a C file, gtksourceview will try to lookup the c:keyword style, if that is not defined it will try to use def:keyword and if that is not defined either it will use def:statement.
The minimal set of styles you need to define are def:comment, def:constant, def:statement, def:identifier, def:type and def:preprocessor, but obviously for good looking schemes some more tweaking is needed, like defining def:error or distinguishing def:string from def:constant etc. You will also probably need to define some language specific things, especially for things like diff files or xml files that do not easily map to those default styles.
As said above we are really looking forward to see style schemes created by our users, thus we started a wiki page to collect them. Beside we are also looking forward including the best ones in GtkSourceView itself: currently we have the classic style (similar to gvim colors) the Kate style (similar to the Kate editor colors) and a Tango style, which however still needs a bit of tweaking since at least in my opinion it looks “too light”. We would like to include a couple more styles in gtksourceview of which at least one for dark backgrounds, so if you come up with a good theme or improve one of the existing ones (in particular tango.xml) do not esitate to tell us!
gedit call to arms
Some days ago lucasr sent an interesting mail to desktop-devel-list pointing out that some modules did not yet release a test version for the next GNOME and suggesting that if the reason was lack of manpower the current developers of the module should post a list of potential tasks in order to attrack new developers.
gedit was in the list that Lucas posted, but that was in part due to the fact that we were working on the gtksourceview 2 port and release was blocking on that. That said, lack of time and manpower is a real issue for gedit these days, so as promised to Lucas here is a list of tasks for gedit.
Note: I am restricting the list to the official gedit tarball, since our third party plugins community is more active than ever and new plugins pop up every day. Beside I am trying to list tasks that are a good fit for new developers, of a size big enough to make the challenge interesting, but without requiring an intimate knowledge of all gedit internals.
There are probably other things I am forgetting and maybe nud or jessevdk have some more ideas and will blog about them.
There are also gtksourceview tasks, but those are for another time :) for now I’ll limit myself to say that help with new .lang files in gtksourceview 2 for your favourite programming language would be very appreciated.
Should you decide to pick up the challenge and try any of the above tasks, keep in mind the following advices:
gedit 2.19.1
First of all, congratulations to Paolo Maggi, who just became father for the second time… I guess that this will leave him little time to work on gedit, but that is surely a more important “release” :-)
I am distchecking gedit 2.19.1 as I write, this will be the first developement release that features the port to the new version of gtksourceview, so to install it you will need gtksourceview 1.90.1 and pygtksourceview 1.90.1
Casual gedit users will not probably note any substantial changes, but if you use gedit to code or to write latex or for any other syntax highlighted language you will take advantage of the new features. Chances are that you will also spot some regressions in the highlighting of your favourite language, so please help us improve the .lang files since we do not know the details of all the syntaxes we can currently highlight: lang files are shipped in gtksourceview and are located in $PREFIX/share/gtksourceview-2.0/language-specs.
The .lang file format is documented on the wiki: http://live.gnome.org/GtkSourceView/NewLangFormat
Obviously even if you don’t spot any regression, there are also plenty of improvements that could be made: since most of the lang files have just been converted from the old format, they do not take advantage yet of the new features of gtksourceview. New lang files are also more than welcome.
The gtksourceview upgrade also affects plugins: if you had any plugins using (py)gtksourceview directly, they need to be updated to the new gtksourceview api.
From the UI point of view, the gtksourceview upgrade affects syntax highlighting color configuration: if you ever tried to customize the syntax highlighting colors from the current gedit preference dialog you know how painful that is. You need to set the style seprately for every tag of every language you use… gtksourceview 2 instead supports style scheme files.
At the moment I totally removed the Syntax Highlighting colors configuration page from gedit preference dialog, but we need to put back a way to at least switch style schemes. A style scheme editor would be nice too, but it requires to design a sensible UI… suggestions are welcome. For now you can set the sytle scheme used changing the /apps/gedit-2/preferences/editor/source_style/scheme gconf key and you can add your own style scheme files in $PREFIX/share/gtksourceview-2.0/styles or in ~/.local/share/gtksourceview-2.0/styles.
At the moment just two styles schemes are included in gtksourceview one called ‘gvim‘ (similar to gedit default colors) and one called ‘kate’, similar to kate default colors… I would really love to have at least a dark-background style scheme, a style scheme using the tango palette and an emacs-like style scheme. Please create and share with us your style scheme!
GtkSourceView Licensing: a social networking experiment
GtkSourceView has been living in a licensing limbo for a long time: we want it to be LGPL - most of the code is - but the original version of which only a bunch of lines remain was GPL.
With GtkSourceView 2 finally arriving (I’ll try to write more about that later, see nud’s blog for now) we felt it was time to bite the bullet and try to get relicensing permission from all the contributors.
If you ever sent a patch to gtksourceview or wrote a .lang file and read this, please get in touch with us.
In fact things have been pretty smooth so far, except for getting in touch with Chris Phelps (chicane on irc), one of the original authors of the first version of gtksourceview, since his email bounces. If you know Chris’ new email address or know any way to get in touch with him please let us know.
Even better, Chris, if you are reading this after googling for your name, please contact us! :-)
By the way, this is my first post from blogs.gnome.org: I’m far from a frequent blogger and advogato always suited my needs, but the new ‘blogo’ is so nice that I couldn’t resist giving it a try. Anyway my entries should still appear on advogato, unless I made some mistakes in the rss configuration.
FOAF updates: Trust rankings are now exported, making the data available to other users and websites. An external FOAF URI has been added, allowing users to link to an additional FOAF file.
Keep up with the latest Advogato features by reading the Advogato status blog.
If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!