Category Archives: Uncategorized

[off-topic] It is not about GNOME but is for Girls

[off-topic] It is not about GNOME but is for Girls

This post will be written in portuguese, because I want to invite girls in my city to participate!

Meninas, nos dias 25 e 26 de outubro de 2013 – no mesmo dia na China hahahaha (coincidência) – acontecerá a primeira edição do Rails Girls. Um evento voltado para mulheres interessadas em se engajar na programação com Rails e aprender um pouco mais sobre Software Livre e desenvolvimento. Eu e vários colegas vamos estar lá para ajudar no que for preciso. Também vamos ter um espaço para dividir com vocês nossas experiências no mundo da Computação, eu vou falar sobre minha experiência no GNOME Outreach Program. As inscrições são gratuitas!! Não tem desculpa para não participar!

Syntax validation – GCP backend

Continuing to talk about Code Assistance Backend, I will introduce my next step on my project. Let’s review which we have in gcp backend.

So, first, we have 4 programming languages backend: python, xml, C and vala. For xml syntax validation, we need to install a extra-pkg called lxml and, for vala, we need libvala pkg.

Talking about vala and libvala, because this was a programming language backend which I implement and I have more idea about how it works. I use a vala class Report to create a new diagnostic tag with some severity (error, warning, notice) which will displayed this diagnostic message on gedit document. A report object is a attribute of another class – CodeContext – that will start to scanning a souce content and will call report when each syntax issues is found.

Yes, libvala turns vala syntax validation very automated. As the same to Python using itself and I think is the same to xml using lxml. But a question about ways to do syntax analysis arose when I decided to build a JS backend. The first thing that I need to search was about some js feature to do syntax analysis and binds to be used between JS and python or vala. Every time that I want a new language as backend I will need to search some package to provide binds between this language and Python/Vala? Maybe could be easy use some packages features, but I, for example, really don’t like to install a lot of packages to be able to use some application. As more packages I installed, more packages conflict I will be susceptible to deal.

Search for a solution for JS Backend, I found a JS minimizer called SlimIt which uses Python PLY to provide JS syntax analysis. So, I think “why don’t we use a PLY based class as abstract class for every backend and just worry about grammar and tokens?” You can ask me: is not really simple implement grammar and tokens. Yes, you are right, but using PLY we will not need to install a lot of packages and, if you could not find a parser to assist you for some language, you can do it by yourself.

So, my new step is use PLY to provide backends for any language which has free context grammar. Begining with JS.


My Vala backend implementation

Hey all,

My Vala backend looks working fine now. I didn’t do all tests, but I can show you how it is working for some kind of errors.

If you forget to declare type (it is simple, but very common for Python/Ruby programmers, for example):


Or you forget to close a brace:


Or a parenthesis:


More examples:


Document file

Following Python backend implementation, the other class which I codified was Vala.Document. For this class I can create some auxiliar classes to works together Vala.Document class update solution.

Vala.Document’s implements Gcp.DiagnosticSupport which is related to Gcp.Document. Gcp.DiagnosticSupport has some abstract methods that need to be implemented:

  • begin_diagnostics
  • end_diagnostics
  • set_diagnostic_tags
  • get_diagnostic_tags

Another necessary method is that one which will be called on Backend on_document_changed method to “diagnostic” gedit document making validations of file for the especific programming language.

In my case, I named as “update”. In this method I include a timeout to parse, following others Backend files. To start the parsing, I gather some document informations as path, text bounds which are used to reference what I need to analyze.

Vala has a Reporter class that make syntax analysis of its own code. So, it is not necessary to create the many parse methods to check the many possibilities of syntax errors.

And you can override some Reporter class methods, which I did to call DiagnosticSupport method responsible for display these errors to user.

So, when your parser find a error, it needs to:

  1. create a SourceIndex object
  2. get begin and end bounds of error that will be used to create a SourceLocation object used in SouceRange instantiation
  3. create a Gcp.Diagnostic object using the informations above and add this on SouceIndex object created in the begining.

Finally, you will lock the mean Diagnostic thread, set your new SourceIndex object as diagnostics object from global assistance and emit a diagnostic updated signal.

Backend file

When I was implement my Vala Backend solution, in addition to metadata files I implement two other files with basically two classes Backend and Document. This post, I’m describing the first one.

Backend’s class implements class Backend Implementation from gcp original source. So, you need reference this class as a abstract class on your code and override tree methods:

  • create_document
  • destroy_document
  • on_document_changed (trigger your method to deal with document update)

I still don’t know why, but I needed to include this lines to make it works fine:

public void peas_register_types (TypeModule module)
    Peas.ObjectModule mod = module as Peas.ObjectModule;

    mod.register_extension_type (typeof (Gcp.Backend),
                                 typeof (Gcp.Vala.Backend));

I “stole” this from C backend code 😛 I will ask my mentors about it, since it is present on backends that was implemented using Vala but I didn’t see on Python’s codes.

Gnome Yearbook

Hey, I’m glad to be present in Gnome yearbook of this year. I received mine via postoffice, since I couldn’t be present on GUADEC in Brno. My yearbook has a world of people, I just could see their faces on pics.
For me was a good surprise seeing that, with my yearbook, I received 2 Gnome stickers ❤ I love stickers!! 🙂 I put one on my netbook, so cute!Image

First week – jhBuild, Code Assistance and PyGtk

My first internship week has passed and this short time was enough to make me feel that I have a lot of things to learn and to do as a junior software developer. Sometimes I feel too junior.

One week before to start my internship period I decided to prepare environment  to development. As I will work in code assistance plugin, I thought the initial requirement is install and run code assistance. I tried hard by myself to install its dependencies and I had I lot of problems that was only solved when I upgrade my vm debian wheezy to sid (of course it would probably work once sid is unstable – i.e. in development – version)

But after executed installation scripts and code assistance was finally built, it didn’t appear on my gedit. /o\
So, my mentor pbor said: hey, Melissa, if you have some doubts or issues about everything, even simple things, ask, ask, ask…

And after my first question I discovered that every hard work that I had to build the environment was waste of time. I need to follow another way, a GNOME developer way. So, I restarted from scratch.

First step – Install JHBuild.
What is it?
For me, the closest comparison is RVM. If you are a RubyOnRails developer, you probably heard about it.
So, using RVM is possible to manage ruby versions without to compromise them. You can have different environments available in your machine and it won’t interfere a lot on your OS.
JHBuild works similarly but for GNOME. You can run a GNOME version (or GNOME modules) in a virtual environment.

And you can think “hey, this turns your life easy”,  not yet!
Yes, I feel my development life easier now, but install JHBuild on my Debian Wheezy was not so easy!
If I could do a advice to Debian Wheezy users, it would be: don’t start right now! If you can, upgrade your Debian to Jessie. When I say “if you can” I’m including problems with a ‘used’ OS. You know when you upgrade a environment used a lot you can face strange problems with compatibility.
But if you have a Jessie you will face less issues related to dependencies of JHBuild and GNOME module set (because GNOME from JHBuild will not be totally separated of your OS).
I just used a Jessie repository on my sources.list and install -dev dependencies using #apt-get install <package>/jessie to get required version of a package. But I had to do some trick to make it works, and for this I was helped by pbor and nacho.

I’ll try to separate every packages necessary to run JHBuild and post here. I asked to myself if someday I would get JHBuild running on my Debian, if it would be possible 😛 and I can say, “yes, you can”

Now I have JHBuild and Gedit 3.9 working fine. And also Code Assistance Plugin, that after JHBuild, its installation occurred so soft. Like a glory! 😛

So what lessons I learned this last week:
1 – Don’t try to do everything alone. Ask more. But I consider that searching manners to solve issues is also a good way to learn. So, search and try, ask and try.
2 – Learn to be a good developer with good developers. If you a

re a freshman, ask help to veteran.
3 – Use JHBuild to don’t disturb your original system.