[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):

Image

Or you forget to close a brace:

Image

Or a parenthesis:

Image

More examples:

ImageImageImage

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:

[ModuleInit]
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 :P 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 <3 I love stickers!! :) I put one on my netbook, so cute!Image

Adding a backend in Gedit Code Assistance Plugin

I’ve noticed that Gedit Code Assistance Plugin misses (or it’s not easy to search) some page like that: https://live.gnome.org/Gedit/PythonPluginHowTo where you can find the steps to create a plugin for Gedit by yourself. Maybe because this plugin are still in development.

This kind of page are important to find more contributors, to auxiliary developers and document the project.  So, I’ve decided to use this blog to show and describe steps that I followed during my development. I got this steps with assistance of my mentors Paolo and Ignacio.  As Paolo said “Code assistance supports plugin itself – plugins of plugin”.

So…

After you have installed JHBuild and been able to use Gedit 3.9 you can start to devel new features for Gedit Code Assistance (Gcp), such as making Gcp supports other programming languages.

First of all, you need to install Gedit-Code-Assistance. For this:

1- Clone Gcp from repository:

git clone https://git.gnome.org/gedit-code-assistance/

2- Using JHbuild enviroment, follow installation steps of README file. Pay attention with dependencies and install them using JHBuild as well.

3 – Test if your Gcp is working fine. To turn it on, you need to select on menu bar Preferences > Plugins > Gedit Code Assistance. Note that, for Gnome 3.10, Gedit Preferences are on top bar of your desktop enviroment. So, you will not find this on the Gedit Window.

After everything has occurred fine, you need to create a space to put your backend and turn it visible for Gcp:

1 – As languages already supported by plugin, create a folder in “backends” with the name of your language. In my case was backends/vala

2 – You can copy files from python folder: renaming to your language (gcpbackendpython.plugin -> gcpbackend<your_language>.plugin, modifing metadatas such as:

Loader (C is default): it is about language that you are writting your plugin.

X-Languages: this is about the new backend that you wanna implement

3 – You need to include somethings in auto tool’s configuration file:

  • In backends/Makefile.am:
    SUBDIRS += <folder_of_your_language>
  • In backends/<your_folder_language>/Makefile.am:
    If you are using vala, use C Makefile.am and change “SOURCES =”, “valapkgs =”, “plugin_DATA”, “EXTRA_DIST = ” and “GITIGNOREFILES =” as convenient.
  • In configure.ac
    – PKG_CHECK_MODULES: create a one related to your language packages
     – AC_CONFIG_FILES: add path related to your Makefile language

Next post I will describe files where you will develop your plugin

backends/vala/Makefile

“I have a dream…”

After FISL’s week, I came back to work on my project and, passed a few days, I was unmotivated about it. This happened for two reasons:
1- I had a deadline to fulfill, but I didn’t get progress in understanding of the issue which I needed to solve. I knew what I need to do and a notion about how gcp tool work, but I didn’t understand how I would do. I was confused about if I was really doing something.
2- I had activities (out of my project) to do and I didn’t have time enough to dedicate in my project. I didn’t realize how to organize my time.

For a while, I considered to give up. I was talking with others interns about my missed deadline and they said “Oh, I also had this problem”.
So, my mentor, Paolo asked me something like: “how is it going?” and completed with “We can help you, but you need to find what problem you need our help” That day I’ve dreamed (or a nightmare) with Paolo and Ignacio. It was funny because I don’t meet them, so, my brain just put their hackergotchis on a body and they talked with me that I need to work and do something.

I woke up anguished! Hahahaha… But I decided to focus on my project and “do something”

And, after some days (really) trying, I began to understand HOW I will do!

I don’t understand why I thought I didn’t do! For my first contribution, I had the same questions about HOW and the same problem with slow progress! But after a slow progress in the begining I improved exponentialy my performance.

And now… I’m progressing.

Spread the word

I’m spending my week attending FISL (one of the most important latin american meeting about free software). It’s happening in the south of my country, as every year. Here I can meet friends of ideas, people who likes, develops and contributes to free software. I can discuss projects, knowledges and learning more and more.

2008 was the first year that I attended this event as a listener, at that moment, I was a freshman and free software and communities were new things. But, this year, I came back as a speaker. I decide to tell everyone about Outreach Program for Women, Gnome, Gedit and PyGTK. I decide motivate women to participate and guys to colaborate and incentivate their colleagues to apply and contribute with her potential.

The title of my presentation was “PyGTK to start a conversation”. I started to talk about GNOME OPW (who can participate, how introduce yourself to comunity, how to know ways to colaborate and others ideas). So I spoke about IRC, discussions lists, wiki, blogs, projects, money, free software communities and GNOME.

After, I discussed about how easy and simple is programming using Python and using Python with GTK interface toolkit to GNOME projects. I showed references manuals on internet and paths to find information, guides and samples.

To close my speak, I demonstrated initial steps to create a plugin on Gedit using PyGTK. The files .plugin and .py, Gedit objects, GObjects and a lot of ways to say Hello World with a plugin on Gedit:
– on terminal (write hello on terminal)
– on window dialog (open a dialog saying hello)
– on buffer (dialog response write hello on buffer)
I didn’t have more time to show others example like say hello (write hello on buffer):
– by toolbutton (create a button on toolbar, click and write hello on buffer)
– by side panel (create a button on sidepanel to say hello on buffer)
– “tab-removed” signal opens a dialog saying: “You say goodbye, and I say hello!” and write on terminal: “Hello, hello…”It was a pit.

Another great thing which happened during FISL 14 was the meeting of GNOME brazilians contributors. This meeting started at the same time of my presentation, but after I’ve presented, I went to meeting room and knew some guys. It was amazing to see how active and friendly they are.
I also could talk to Luciana Fujii (a previous brazilian participant of Outreach Program Women). She encouraged me, shared her experience and invited me for participate to others two interesting event, a course where she taught GTK for women (as I’m a beginner, I could improve my knowledges) and the meeting of Women at Technology.
This last event was opened to any girl, who is involved in the technology universe, could share facts and situations that women need to face, day by day, after their choice to learn and to work in a technological space.

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.
See https://live.gnome.org/Jhbuild

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 :P 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! :P

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.

Follow

Get every new post delivered to your Inbox.