Sunday, December 8, 2013

Tips for newcomers!

I composed a journal entry for the GNOME Journal sometime in June of 2011 but since the journal seems unrevivably dead, I thought, it's a good idea to share it on my blog.

Now that FOSS Outreach Program for Women internships is at it's verge of its action, what better time would it have been for this post to come.

Here it goes:

Becoming A New Contributor (Lessons from Empathy)

GNOME+Ubuntu was the first desktop and OS combo I ever used since installing the first linux distribution on my computer. GNOME made my transition from Windows very simple. As I explored more of it, I started to love the flexibility Linux provides and decided never to go back to the world of Windows which had always been hard on pocket. GNOME was my catalyst for this change!
Contributing to an Open Source project is more of a passion to learn and grow in an environment where all doors to knowledge are inherently open, rather than a compulsary chore that you are bound to complete in a set time duration. A community where everyone is willing to share his/her knowledge with you, without expecting anything in return, becomes an abundant, friendly sea which you are free to explore and collect the best of the pearls from, as you get to implement the aggregated knowledge mixed with your own skills and creative ideas and receive appreciation for every little effort of yours! The GNOME community is one such community I have witnessed :)

Getting started is the hardest part in any new endeavour. For a developer, the understanding of the development environment, having sound grasp of the developer tools and understanding the underlying APIs is what will lay the foundation for your contributions. The best way to learn them in fun manner is to exercise with them and to explore them as their need arises! GNOME's outreach program for Women and Google's Summer of Code are excellent programmes with which you can get in touch with experienced mentors who will help you overcome all sorts of fears of working on large projects with lines of code in some tens of thousands, and will be having a to-the-point answer to most of your queries. Also you'll simultaneously achieve a decent amount of stipend for your hard-work in return!
GNOME contribution becomes very easy for a FOSS enthusiast who uses it and takes it in high regard. You can contribute in many ways irrespective of you having a technical background. Contributions to GNOME can come in any of the designing, developing, documentating or marketing forms. I chose development simply as this was the most intutive way for me. I used to be just a daily user once. Slowly, I began reporting bugs as I experienced them and placing my desired feature for improvisation of applications I used and cared about. I also remember acting as a bugsquadder for a while.. And one fine day (which barely marked five months of first installing linux on my machine), I builded Empathy from source (thanks to Danielle and jhbuild :). It was tough for the first time and I started to code and debug using the Eclipse CDT IDE instead of using the in-built development environment Linux offers; I wish I had worked with "Beginning Linux Programming" by Niel Mathew and Richard Stones[1] or something similar beforehand! This book will prove an excellent reference if you are new at developing in Linux environment and want to boost up your development time through the fast and efficient tools your Linux distro has in store for you. After going through this, you will know how to be sure that your code is lint free and contains no memory leaks. My first developer contributions began with introducing improvements to my favorite application in GNOME- Empathy[2] which is mostly written in C programming language.

The foremost thing to begin is understanding the Git version controlling system[3] (GNOME uses that as do many worthy projects which you admire and use including the Linux kernel) which would be easy for anyone who had used any version controlling system in past (was not the case with me though). Next comes the APIs which the GNOME applications use. Most ubiquitous ones being, the GTK+ user interface API [4] and the core, GLib[5] and GObject[6] APIs. The An excellent mention over here would be the Andrew Krause's "Foundations of GTK+ development"[7]. For working on Empathy particularly, one has to understand the Telepathy specifications[8] aided with the Telepathy Developer's manual[9]. Yes they are huge but the approach should never be to understand all at once (I still keep unrolling them as need arises and when I feel like contributing more :).

People get to learn a lot with examples and I acknowledge the wealthiness of apt illustrations in almost all the important APIs you would need getting started ensuring a steep learning curve. To aid this, I also used to look up alternative full working examples for instance one might seek Tim-Philipp Müller's tutorial on GTK+ 2.0 TreeView[10] (you are right, I didn't came across the "Foundations of FTK+ development" till then).

The phase when I got involved in GNOME as a developer was a rocky one. GNOME was transitioning from version 2.32 to 3.0 and so were the many underlying core APIs. GTK 2.0 to 3.0 transition infused a series of API and ABI breaks rendering all applications built on top of it unbuildable and the developers were usually found adapting to the changes for most of the time. Albeit this, my starting was a lot eased with GNOME's Outreach Program for Women Internships 2010 and the supporting hand of an experienced Empathy and Telepathy developer, Danielle Madeley, who was my mentor. She was there to help me out whenever I got stuck and she is always ready to help even now! See how good and welcoming people of this community are! (One of the reasons I love GNOME so much! :)

Empathy is a multi-protocol messaging client which offers one-to-one and multi-user text chats and one-to-one voice and video calls over supporting protocols. At the first view of Empathy's code, nothing seemed familier to me except the C language constructs. I was clueless about how the pieces were put together. The overall design was utterly uncomprehendable with over 96k lines of code increasing at a tremendous rate. Now with huge applications like this, getting to know the entire application is not possible in a short duration if one has to be immediately productive so I decided to maintain my focus on multi-user chat features and bugs for the internship duration. Having sound knowledge of object oriented systems helps and with a little understanding of GObject one can begin to relate things, associate them and see how data flows among modules. Due to its object-oriented design, Empathy has all the advantages of any modular piece of work just like any other project based on GTK. Each file is a single class having certain set of private encapsulated data it works upon, and only a required subset of the data is accessible to other "classes" by means of public getter and setter "methods" while abstracting other data. Classes inherit other GObject classes and implement GObject interfaces. C immitating C++ ! Sounds cool, doesn't it? I was immediately a fan of GObject and its umbrella- generic C library, GLib, which besides Empathy is used by many other GNOME applications.

Owing to the fact that Empathy makes use of a lot of open source projects and libraries, one might wonder how can anyone actually begin to work without spending days of learning on it. The answer to it is Devhelp[11], a GTK+/GNOME browser for API documentation. It works natively with a library's gtk-doc generated documentation. It has this extremely useful search tool using which you can find the exact class/constant/function/signal you are looking for, almost instantly, for say, implementing some new feature. One easy way to keep devhelp updated with the latest documentation is to build the latest versions of libraries with "--enable-gtk-doc" option before installing and modifying the XDG_DATA_DIRS environment variable to include the "library_install_prefix/share" path before launching devhelp. Another useful tool is Git's grep tool using which you can locate the exact line of code you want to be at in a snap! So no more getting lost in the maze-like repository! Debugging and tracking sessions make one learn a lot! Among others, for debugging solely I got to experience new and useful tools like D-Feet[12], the D-Bus debugging tool to check values returned by methods on system/session buses and Wireshark[13] to monitor packets sent to and received from a network. Knowledge of these makes a prolific developer.

The work I completed under internship spanned a wide range of bugs the details of which have nicely been listed in my blog-posts[14] between December 2010 and March 2011. You can also track them from the slides of my talk titled "Contributions made by a newbie to the free desktop's Empathy" at GNOME.Asia Summit 2011[15]. All of my work branches have been merged upstream now and you'll be able to enjoy them in Empathy 3.2 :) Do let me know if you like and appreciate them. It keeps me motivated to contribute even more and gives me the satisfaction of impacting a large audience- the rare feeling which GNOME contributions can bring to someone!

Being a part of the GNOME community allows you to be with highly motivated people and think like them. If you are still wondering, or if there is still something stopping you from contributing, just know for once, that being here requires you to be ambitious and if you are here, you'll see yourself as a worthier person who is learning something new each day!

GNOME is lovable. GNOME reciprocates if you love it. Hope to see you soon; happy contributing!




LINKS
[1] http://www.wrox.com/WileyCDA/WroxTitle/productCd-0764544977.html
[2] http://live.gnome.org/Empathy
[3] http://git-scm.com
[4] http://developer.gnome.org/platform-overview/stable/gtk
[5] http://developer.gnome.org/glib/stable/
[6] http://developer.gnome.org/gobject/stable/
[7] http://www.gtkbook.com/home.php
[8] http://telepathy.freedesktop.org/spec/
[9] http://telepathy.freedesktop.org/doc/book/
[10] http://scentric.net/tutorial/treeview-tutorial.html
[11] https://live.gnome.org/devhelp
[12] https://live.gnome.org/DFeet/
[13] http://www.wireshark.org/
[14] http://chandniverma.blogspot.com/
[15] https://live.gnome.org/GnomeAsia/2011Summit/Slides

Wednesday, October 30, 2013

Mentoring for Empathy

It's a great pleasure for me to announce that I will be mentoring for Empathy for this round of Outreach Program for Women Internships.

So come on #empathy on GIMPNet and show us you are interested.

Cheers!

Monday, September 30, 2013

Got some perks

Yesterday, Dr. M.C. Saxena visited my residence.

On the auspicious occasion of Navratre beginning (which is 5 days from now), an IT Centre is to be inaugurated in MCS Group of Colleges campus. He asked me if I could join the same and help run it, and I agreed.

So, with effect from the 7th of October, I'll be working on a UK based project that we have accepted (details not yet disclosed). I'll have more time for participating in algorithm competitions (again, yay!). Looking forward to new schedules!

PS: I still love GNOME and will continue contributing to it and underlying technologies in free time. Cheers!

Monday, August 19, 2013

(Re)discovered a bug in Gtk+ - Clickable widgets inside a GtkExpander's label-widget

GtkLabel is one of those (which those? didn't find the answer- lazyweb) widgets which do not have a window of their own; so they cannot receive events. To make a label clickable, you have to wrap it inside an GtkEventBox and receive "button-press-event" on the event-box. That's the simple part.

Now when I apply the same technique and wrap a GtkLabel which is a part of the Label widget of a GtkExpander in an event-box to make it clickable then button-press-event isn't generated! If you think there's something peculiar with labels and think you can use buttons-with-no-relief instead of labels in the label-widget of GtkExpander then no, that's not an option since even buttons receive no events inside the label-widget of a GtkExpander.

..But, according to this, the events are delivered first to the child widget then to parent widgets so the label should have received the event in the first place! It turns out to be a bug in gtk+ which was similar to the one described here.

Here's the code with a hack which solves my problem for the time-being:

#include  
GtkWidget *expander;
gboolean
hacked_idle (GtkWidget *hbox)
{
     g_object_ref (G_OBJECT (hbox));
     gtk_expander_set_label_widget (GTK_EXPANDER (expander), NULL);
     gtk_expander_set_label_widget (GTK_EXPANDER (expander), hbox);
     g_object_unref (G_OBJECT (hbox));
     return FALSE;
}

void clicked(GtkButton *button, void *which)
{
    g_debug ("%s clicked\n", which);
}
gboolean button_pressed (GtkWidget *widget,
    GdkEvent  *event,
    gpointer   user_data)
{
    g_debug ("label clicked with button %d", ((GdkEventButton *)event)->button);
}
int main(int argc, char **argv)
{
    gtk_init (&argc, &argv); // could technically do autolist_add(main_init, gtk_init); but it wouldnt buy me anything
    GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    GtkWidget *vbox1 = gtk_vbox_new (FALSE, 0);

   gtk_container_add(GTK_CONTAINER(window), vbox1); 

    expander = gtk_expander_new(NULL); 
    gtk_expander_set_expanded(GTK_EXPANDER(expander), TRUE); 
    gtk_box_pack_start(GTK_BOX(vbox1), expander, FALSE, FALSE, 0); 

    GtkWidget *hbox = gtk_hbox_new(FALSE, 0); 
    gtk_expander_set_label_widget(GTK_EXPANDER(expander), hbox); 

    GtkLabel *label = GTK_LABEL(gtk_label_new("The Label")); 
    GtkWidget *event_box = gtk_event_box_new ();
    gtk_container_add (GTK_CONTAINER (event_box), GTK_WIDGET(label));
    gtk_box_pack_start(GTK_BOX(hbox), event_box, TRUE, TRUE, 0);
    g_signal_connect (event_box, "button-press-event",
                      G_CALLBACK (button_pressed),
                      NULL);

    GtkWidget *edit_button = gtk_button_new_with_mnemonic("Edit"); 
    gtk_box_pack_start(GTK_BOX(hbox), edit_button, FALSE, FALSE, 0); 
    gtk_widget_set_sensitive(edit_button, TRUE); 
    g_signal_connect(edit_button, "clicked", 
                     G_CALLBACK(clicked), 
                     (gpointer)"Edit");

    GtkWidget *delete_button = gtk_button_new_with_mnemonic("Delete");
    gtk_box_pack_start(GTK_BOX(hbox), delete_button, FALSE, FALSE, 0);
    gtk_widget_set_sensitive(delete_button, TRUE);
    g_signal_connect(delete_button, "clicked",
                     G_CALLBACK(clicked),
                     (gpointer)"Delete");

    GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(expander), vbox);
    // ... put some junk in the vbox 
    gtk_widget_show_all(window); 

    g_idle_add ((GSourceFunc) hacked_idle, hbox);
    gtk_main(); 
    return 0;
}




I filed a bug @bugzilla for the same: https://bugzilla.gnome.org/show_bug.cgi?id=705971
Relevant bug in Empathy: https://bugzilla.gnome.org/show_bug.cgi?id=679919

Wednesday, July 31, 2013

Going on...

Ahoj Planet!

Good news is that the patches I presented in the last post have been verified and merged with a few changes:

The remove contact dialog looks like this now with the name of the group displayed-



Only one of Join and Leave chat menu-items gets displayed in the top of the 'Conversation' menu-



(and with these we move one step towards having ability to close a chat window without leaving a chat.)
Besides these, other works submitted for review are:
  • Show typing icon against composing members of a private MUC or a chat-room



  • With my patches, the search-bar will now hide itself when an action is selected from the contact-roster after search is performed. This will make it look smarter and will improve its promptness for the next search. See for yourself in action! (Bug 643183)
  • Submitted a patch to close Bug 698530 - adding contact to group does not cause them to leave Ungrouped until Empathy restart.

    There's so much to be done. Stay tuned for more polishing!

Friday, July 5, 2013

Back to shooting bugs!

I had been underground as I was not well. I was too tired and was advised rest from work.

When I came back I picked up my pending branch on telepathy-networking in gnome-chess since work begun should not be left incomplete. I realized that my branch had diverged from gnome-chess master to quite some extent :( so I decided to fix and complete that at any next stretch of peaceful time such as the GNOME India hackfest being planned. :)

Meanwhile, I'll continue with bug-fixing and triaging, since the tiniest things are also important.
I have proposed fixes for:

  • Bug 643755 - Create Join Chat and Leave chat menu items for the conversation menu in MUCs (multi-user-chats)
  • Bug 698840 - "top contacts" who are offline are incorrectly showing in Empathy's contact list
  • Bug 585440 - Deleting a contact in multiple groups (in Empathy's remove contact dialog)
                           


    I am currently looking into Bug 703487 - Show typing icon against composing members of a MUC, which was lost in obsoleting old code and needs to be redone using the new API.

Friday, March 15, 2013

Review on GNOME 3 Application Development Beginner's Guide

A couple of days ago, I got contacted by folks at Packt Publishing to provide a review about GNOME 3 Application Development Beginner's Guide, written by Mohammad Anwari who has over 13 years of experience in software development and has been working with Linux-based systems and applications in GNOME, and Qt platforms.


I haven't got a chance to peek into the chapters yet but I'll be getting a free e-book to charge my eyes from very soon. Advertisements declare about the book describing GNOME 3 development environment installation on many popular linux distributions, best-practices from mockups upto running applications, accessing data with EDS, i18n and localization, Unit testing framework in GLib, Gdk and Gtk+ and multimedia programming with GStreamer among others which seem a lot in just one place. I'll hopefully scan it soon and provide more precise reviews thereafter.