gedit 3.2.6 released for OS X (native)

As you might know, gedit has been ported a while ago to run natively on OS X (and on windows for that matter). Lately, the OS X port has been lacking updates. This is mostly due to the huge changes that were introduced in 3.x in much of the stack, and a lack of time. However, over the last few weeks, I worked on and off to get a proper OS X application released for our latest gedit (3.2). The installation is a simple drag and drop of the application bundle (as expected).

Improvements

With respect to the previous release (apart from having all the 3.2 goodness), the integration with OS X has been improved. For example, we now ship binaries for Tiger, Leopard and Snow Leopard, integrated native apple spell checking, fixed issues with translations and fixed various issues with keybindings and the global menu (which annoyed a lot of people in 2.32 using different keyboard layouts).

After installing gedit and launching it, you should see something like the following:

Integration

As you can see, we have spent some effort (just as previously) to integrate gedit in OS X natively. Most of this effort is not spent by gedit, but by a small group of people doing amazing work on the quartz backend of gtk+ and on mac application integration (yes, that’s you John Ralls). I really want to thank everyone spending a lot of effort to integrate gtk+ (quartz backend) and GNOME applications (mac integration) into OS X. Without these guys a gedit port for OS X would simply not exist.

Build process

Whereas gedit for OS X was previously built by me in mixed environment of jhbuild and custom checkouts with various patches (pushed into github), this time I decided to handle things more properly and integrate the whole build process in the gedit tree as a jhbuild moduleset and accompanying patches. This also solves the issue with the previous binary for which we did not strictly adhere to the GPL, in the sense that it was almost impossible to recreate the binaries from source. This time, you can simply follow the instructions in the osx/README file and everything should be built for you the same way I built it on my machine. This meant I started basicly from scratch, which is also why it took quite some time to get everything working as expected.

Porting applications

I think that gedit is a great application showing how you can port an application using a lot of GNOME/freedesktop technologies to another platform (hopefully we will have a 3.2 for windows soon too, poke nacho ;) ). gedit uses dbus, libpeas (gobject-introspection), plugins (C and python), printing and more. All of this works (or at least should work :) ) on OS X, and we are getting more native with each release. If you are interested in porting your application to OS X, please feel free to have a look on how we do it for gedit.

Bugs

I expected a series of bugs and releases for gedit 3.2.6. On the one hand a lot of software has seen a lot of development, none of which were tested on platforms like OS X (or windows). On the other hand, I’m still expecting some issues resulting from building binaries on one machine for different distributions. For example, the first release was quite a disaster, crashing on launch due to some issues with iconv and a set of hard coded paths (which worked on my machine, but obviously not on others :) ). Anyway, I would like to invite anyone running OS X to try and install gedit 3.2.6 and report any issues in gnome bugzilla!

Posted in gedit. 33 Comments »

gedit code assistance plugin

Just a quick update on the gedit code assistance plugin (see this previous post). We moved development from github to gnome infrastructure. You can find the repository here: http://git.gnome.org/browse/gedit-code-assistance. There is also a first release of the plugin available on the gnome servers (http://ftp.gnome.org/pub/gnome/sources/gedit-code-assistance/0.1/).

Don’t expect it to be very stable. It should work, but it is currently still somewhat prone to crash. Since it is written in vala (thus C) this unfortunately means that it will crash gedit as well. So use on your own risk :) . For those running fedora 16, packages will be available soon.

I will try to work on this on and off if I find the time, feel free to pitch in though!

Posted in gedit. No Comments »

gedit clang plugin progress

A quick update on the gedit clang integration. Here is a screenshot of the latest visualization of errors in source code:

gedit clang plugin

You can checkout the code on github for now: https://github.com/jessevdk/gedit-code-assistance. If you want to try it out, install the gedit-devel (>= 3), llvm and llvm-devel (>= 2.8) packages and compile the plugin (see the README for more information).

Posted in gedit. 12 Comments »

New gedit goodies

Just a quick update of what I’m currently working on:

clang integration in gedit

That’s right, that’s clang integrated in gedit (with the very nice libclang). For now only error reporting is implemented but libclang will also gives us the AST (allowing fancy stuff like static analysis, referencing, symbol browsing, etc.). In addition, there will be auto completion in the near future.

You can’t test this, you can’t find the code yet anywhere, this is just to tease you.

Posted in gedit. 20 Comments »

Rhythmbox webinterface plugin

A while ago I managed to buy an iPad. I am using/planned to use it for various things. One of those things was to be able to remotely control my music player (which is nice when sitting outside on the terrace, having a small party etc.). The ‘Remote’ application that exists to control iTunes works really well, however I don’t really use iTunes. So I thought I would have a look on how to do something similar with Rhythmbox (or Banshee for that matter). I remembered something about DLNA and uPNP and tried for some days to get this to work, but I really got nothing. I don’t know which side is to blame, but in the end I gave up trying to make it work.

Then I thought it might work just as well through a webinterface, why not. I looked for a suitable plugin for rhythmbox, but unfortunately most of the 3rd party plugins are not ported yet to 3.0. Since I thought it would be fun and a nice opportunity to employ some of that shiny, new and hip css3/javascript/jquery/ajax/websocket, I made a plugin for RB to do just what I want.

TeleMote Rhythmbox plugin

It features all the basic things that I want from a remote control. It will show you a list of playlists/sources, followed by a list of artists (for the selected source) and finally a list of songs for the selected artists sorted by album. You get the basic controls to play/pause, skip songs, repeat/shuffle and control volume. In addition, you can also set the current selection as the current playlist. Finally you can also simply queue some songs (those blackish boxes at the bottom of the screenshot) which will be played as soon as the current song ends playing (this is all just rhythmbox functionality exposed and nothing new).

There are some fancy (useful) animations in the UI and in general I kind of like the look of it. I wouldn’t call myself a “designer”, so if anyone wants to jump in and improve some css, please feel free. The plugin is hosted on github:

http://github.com/jessevdk/telemote

Note: You can save your breath preaching about how Apple is evil etc, I’ve heard it all before…

Posted in gedit. 19 Comments »

gedit gobby collaboration

After some more hacking we have most of the functionality ready for real collaborative editing in gedit. Here is me and Armin collaborating (me with gedit and Armin with gobby, sorry, interface in Dutch):

In contrast to my previous post, this version now properly handles its sessions, does error handling etc. The only thing that is really missing right now is undo/redo, which is tightly coupled to GtkSourceView at the moment in gedit. We would need to make the undo handling less specific to use infinote undo/redo for shared documents.

When all of this more or less works, the next step will be to use telepathy tubes to allow sharing documents directly with one or more of your contacts. The idea is that you can offer a collaboration session to your contacts. gedit will then internally run an infinote daemon, offering a virtual document store made up of the open documents in the gedit window. All the necessary components are there, so it should be fairly straightforward to do.

To finish, a little teaser screencast: (youtube, ogv)

Posted in gedit. 11 Comments »

gedit collaboration plugin

Just finished a big chunk of a new gedit plugin which uses the excellent infinote library (gobby, libinfinity) to do collaborative editing. Being pretty tired, I’ll keep this post short, but be sure to get an update on the plugin’s progress soon :)

Credit goes to the rocking infinote API and Armin from gobby fame, where all the hard work is done. The code plugin is currently hosted on github, but we will most likely move it to gedit-plugins once it matures. If you want to try it out, be sure to fetch the libinfinity 0.4 stable branch from git (there were a few API additions and small bug fixes to make it work with gedit).

Posted in gedit. 19 Comments »

About snippets

I think most people know that besides being a very light weight, and simple text editor for GNOME, gedit can also be “transformed” to a more powerful editor using the many plugins is supplies. One of those plugins is the Snippets plugin, and I would like to point out some of its more advanced features that even most of the gedit developers don’t know about.

Snippets is featured by virtually all source code editors in one way or another. It provides an easy way to insert/activate small templates in your document with some variables, or placeholders to quickly suit it to your specific use case. Placeholder can have default values, you can mirror placeholders in multiple locations, and you can specify where the cursor needs to end up when all the placeholders have been visited (you can read more on basic functionality of snippets in the gedit help). I would like to discuss four features that might be less well known.

1. Python placeholders

Python placeholders are placeholders that execute arbitrary python code to provide the text to be placed at the placeholder location. The placeholder syntax is as follows:

$<n:[k]: python code [return string] >

Here n is the optional placeholder tabstop as with other placeholders. If a python placeholder does not have any dependencies (implicit or explicit) on other placeholders, you will be able to tab to it by that tabstop. The tabstop can also be used to refer to this placeholders’ contents in other placeholders. The second optional modifier is [k], where k is one ore more comma separated tabstops referring to other placeholders. These indicate explicit dependencies (I’ll explain them later).  In the python code, you simply return the string you want at the placeholders location. In the code you can use gedit environment variables for snippets (like $GEDIT_CURRENT_DOCUMENT_PATH) and references to other placeholders (using $n). This will provide you with a kind of mirror placeholder doing a particular transformation on one ore more other placeholders. Python variables can be shared between multiple python placeholders  using global. This is where explicit dependencies come into play. Snippets does not automatically find out that another placeholder might depend on a change in a global variable, and thus should be updated. Defining the dependencies explicitly ensures the placeholder will be updated when any of its dependencies has changed.

For an example of this more advanced functionality, take a look at the gobject snippet provided for C headers and C sources. It makes extensive use of the python placeholders and is quite a nice way to bootstrap gobject classes.

2. Regular expression placeholders

Python placeholders are very powerful, and using the re module, you can do regular expression substitution quite easily. However, regular expression transformations are quite common, and a special placeholder is available which makes it easier and cleaner to use regular expressions. The syntax is the following:

${[n:]input/regular expression/substitution[/modifiers]}

Here n is the usual tabstop, input is the text on which you want to apply the regular expression. This can be either another placeholder (a number) or an environment variable such as GEDIT_SELECTED_TEXT (useful when you activate the snippet on selected text). The regular expression is a regular expression conform the python re module. This will be searched for in the input (note: this means it does not have to exactly match the input). The last part specifies how to substitute the match. Here you can use \n to backreference matched groups in the regular expression. Additionally, a special syntax allows you to apply a small number of transformations on the backreference using \<n,modifiers>. Modifiers can be one or more of the following:

  • U: Uppercase the matched group
  • L: Lowercase the matched group
  • u: Uppercase only the first character of the matched group
  • l: Lowercase only the first character of the matched group
  • t: Title case the matched group

Combining them can be useful if you want to want to capitalize only the first word, for example: \<0,Lu>. This will first lowercase the match, and then uppercase only the first character.

The last part of the regular expression placeholder specifies a set of optional modifiers for the regular expression matching equal to the modifiers in the python re module. One last feature is the use of conditions in the substitution part of the placeholder. Using the syntax (?n,truepart,falsepart), you can substitute a group depending on whether it matched or not (useful for optional groups). These can also be nested, so you can build more complex conditions.

3. Dynamic snippets

A new feature was recently developed and is currently available in the development releases (2.29.x): dynamic snippets. Snippets now exposes two functions on the gedit internal message bus (which is used to enable inter plugin communication). The message bus is similar to how you would use dbus, but just for internal use. It allows plugins to hook into each others functionality (for example, you can manipulate the file browser plugin in many useful ways using the bus). For snippets, the following two messages are available:

  1. /plugins/snippets.activate (trigger[, view, iter])
    When this message is send, the snippet corresponding to the tab trigger <trigger> is activated. You can optionally specify the view and iter where to activate the snippet, by default the current view and cursor will be used.
  2. /plugins/snippets.parse-and-activate (snippet[, view, iter])
    This message enables the dynamic snippets. Basicly, you provide the full snippet and optionally the iter and view where to activate it. This provides a very powerful mechanism to use all of the power of snippets from other plugins. I use this in one plugin (gedit-commander which I will talk about at some point) to dynamically build a snippet for a doxygen documentation of a function declaration.

4. GtkSourceCompletion integration

The last thing I want to show is the recent integration with gtksourcecompletion nacho recently blogged about. Before, snippets implemented its own completion popup for when there are multiple snippets with the same trigger. This popup was really quite horrible and had a lot of usability problems. This has now been resolved in the development version (2.29.x) using gtksourcecompletion. One additional feature is the use of multiple default values for placeholders. Using the syntax ${n:[value1,value2,value3]}, you can provide multiple choices for the default value. When you tab into this placeholder, a completion popup will show you the available choices so that you can quickly pick one. This is particularly useful for example for CSS snippets, where some CSS properties have a specific set of valid options.

Defining a placeholder with multiple defaults

Defining a placeholder with multiple defaults

Activating the snippet

Activating the snippet

I’ll try to occasionally highlight other hidden gems in gedit, until then…

Posted in gedit. 9 Comments »

gedit 2.28.2 released for OS X

Just a quick post to inform that gedit 2.28.2 has been release for OS X. This release includes the work to make it possible to open files with gedit from other parts of OS X (such as with finder, or using the command line ‘open’ utility). There has also been a fix in the automatic updates plugin so that it now actually works on OS X. Also, gtk+ has been updated to 2.18 in this release. Enjoy!

Download: http://ftp.acc.umu.se/pub/GNOME/binaries/mac/gedit/2.28/

Posted in gedit. 19 Comments »

New gedit plugin: multi edit

We recently landed a new gedit plugin in the gedit-plugins module named ‘multi-edit’. This plugin allows you to create multiple edit points in the document by which you can simultaneously edit your document at multiple places. I myself found the plugin very helpful in many, otherwise tedious, editing tasks. Although the plugin was written from scratch, credits should go to Jon Walsh who wrote a similar plugin and on which the ideas for this plugin were based.

The new plugin introduces a new ‘mode’ in which you can do multi editing. You enter this mode by Ctrl+Shift+C, and once enabled you can start inserting edit points manually by pressing Ctrl+E at any point in the document. Additionally, you can use Ctrl+Home and Ctrl+End to respectively insert edit points at the beginning or end of the line automatically (it will also skip to the previous/next line so you can quickly insert edit points at the beginning or end of some lines). When you start typing the inserts/deletes will be replicated in all the edit points. You can then press Escape to remove the additional edit points, and press Escape again to finally quit multi edit mode.

In addition to inserting multi edit points, it also features column editing when you are in multi edit mode. This means you can select a part of the text, and press Enter to make the selection into a column selection. When you then start editing, it will edit the whole column (just as if you would have inserted multiple edit points manually and removed the text in the column).

You can watch a short (somewhat lame :) ) movie showing this new plugin: http://www.icecrew.nl/files/gedit/multiedit.ogv

Posted in gedit. 4 Comments »