segunda-feira, 27 de janeiro de 2014

Now I have something really consistent!!

A few days ago I was feeling a little discouraged: I worked in the code and was thinking that nothing was going on. But I continued to develop and suddenly things got very close to what was planned for the midterm delivery! I'm still in the middle of the way, but very happy with the outcome so far. So, I'm very motivated again! Enough talk about me and let's talk about what has been done.

What I did in the last days

Creating function to load / dump locations info
I was studying the files from GTG trying to understand how and where it saved user data. My goal was to save the locations that the user marked in the map. I tried to make a parser, but Parin told me to use an existing file in GTG to deal with save and load, more specifically two functions : _store_pickled_file and _load_pickled_file , which store locations (by converting object into a byte) and allow load this locations (by a byte being converteded in a object). It uses pickle - Python Object Seralization and it turns much more easy to manipulate the data. Thus, the ground is prepared for the next step, which is to add location to a task, and save them to be shown each time a task is opened .

Add / Remove location to/from the task
To develop this feature , the idea was to use the id of each location , which is unique, and get to identify them and save them in a file on disk. Thus, for each location entered, I should keep: name, latitude and longitude.
That gave me some problems: - The first task I add locations works ok, but the second, when a location is added to it, overwrites the first task's name and shows it's location plus previous tasks locations. It was wrong!

    Print with the bad bad behaviour >:/

To fix this,  I create a method to clean-up, and the list of locations and id of the task are setted as a empty list and a empty string, respectively.

    Different tasks and different locations being shown on it

Save the last location 
The purpose is save the user's last location. Thus, when the user is offline, the map could be oppened with latest user's location, facilitating the visualization.

    You are offline and that's your last location

Treat the user location differently than other markers
Here I had to deal with the initial location of the user in a different way from other locations, preventing this initial location to be deleted. The color of this initial location is red, to highlight on the map, and has a different logic: it is set only when the user is online. When the user is offline, it is shown in map. In the future I intend to change that label to something more beautiful.

Treat release button event instead of button press event
This change was made because of the following problem: when the user was setting a marker somewhere, the cursor was changing to drag cursor when it should remain the same hand-opened cursor.
LibChamplain does not handle the button-release-event when button-press-event
is being treated by geolocalized-tasks, keeping the cursor as a closed hand. If we treat the button-release-event, the behavior is according to what we expect.

Show the location description to its name
The last thing I did. I studied the code of gnome-maps and realized that it uses Gnome Geocode Reverse
to get the location name directly from the map. This is very powerful and very cool. You can set a location directly, and it returns the name of the place for you.
I was doing it synchronously, with geocode_reverse-code(). Parin warned me that this could be annoying for a user with slower internet connection and asked me to do this asynchronously (geocode_reverse-code-async).

    It's legen...

    ....wait for it...

    ...dary!  ;-)

And final result in a gif

That's it for now. I'm working in the next steps of my planning. If you have any question, something to correct, ask to me, or comment :-)
See you in next post.

quinta-feira, 16 de janeiro de 2014

Technical problem solved!

The problem
I was having a technical problem that was unsolvable to me. It's  about the context menu, that should be hidden on clicking/right-clicking somewhere else.

Parin told to me to insert some debbugs in the code to try to understand what was happening there.
To resolve it, the ideia was :
to prevent that more then one context menu were created every right mouse click, I have to ensure that the context menu will be closed if another instance of it is opened, in other words, I have to ensure that just one instance of the context menu is open each time it will called.
Thus,  the verification I'm doing is:

            if (self.context is not None):
                self.context = None

With it, I verify if the context is the only one; if it is not, the context menu is removed and the context is assigned with None.

      Gif to show how it is working well :-)

Parin told me also that a UI file should be used for large UIs and I should create a menu inside my code and add the options right there. Then, I insert the content of UI file in my code.

My branch on github is it, in case you wanna see my progress:

If you have any question, let me know.

See you in next post!

domingo, 12 de janeiro de 2014

Welcome 2014, a lot of work to do!

**This post should have been posted last week, but shamefully, it was among the drafts, my mistake :-( **
I had a little vacation since 12/23/2014 until 01/01/2014 and it was so nice, I've been in Portugal and felt a little close to Brazil, my country :-)

Until now
While I was at the hotel, I was making small adjustments to the plugin, but without internet access, and a use case in which I had not thought about happened: what about the user is without internet access? That was my case and when I ran the program, it returned many errors.
My solution was not make the map available if the user is offiline. Thus, the program becomes more robust. I presented this solution to Parin and he suggested me that I should make the map avaible when the user is offline. And show the last user location. Parin also suggested me to take a look on the ChamplainFileCache, which I had relative performance. I take a look on gnome-maps's code and decide to use ChamplainMapSourceFactory. For now, when the user is offline, a map is shown, but  not the last user's location, yet. I spent a lot of time, searching and reading  to understand what must be done.

- Now the plugin allows the user to insert and remove markers.\o/
- I also made some fixes to install GTG properly.

To do soon
- Another suggestion from Parin: standardize the cursor to be a drag cursor and only turn the curser in a arrow when the user uses the mouse's right  button, to hold on the map or to make markers on the map.  
- Finish the problem to show the last location for the user when he is without internet acess.
- Integrate direct "tagging" with map's position (add a tag on a existing task)

See you in the next post!