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.

Friday, February 8, 2013

Status of GlChess in GNOME Games

A while ago, I was found working on GNOME games. GNOME Chess work is on a hault due to lack of reviews at Telepathy's end and the focus has shifted to Allan Day's designs for the control-center's Date and Time panel but the effect of my work on gnome-games module was still lacking a write-up.

The long due promotion type selection dialogs have been given the correct place in the game where they pop up right after the player has moved a pawn to the 8th rank(row). This work-branch has been merged to master and here's how it looks while playing:



So now one has to select his pawn's promotion type when required and not predict his requirements before the game begins. The corresponding setting in the preferences dialog which was also not working as expected, has been reduced in favour of this.

Thursday, September 27, 2012

GlChess and Telepathy DBus-Tube networking and the Hidden Inventor in Me


Premise

I began working on providing networking support to GNOME Games at the verge of GNOME 3.4 release. Now 3.6 release is around the corner and many people are happy about it. So am I, but more about the work I am doing and of which, sharing here with you, a glimpse. It began with a curious part of me which was left cliff-hanging and wanting to know more after a very live and exhilerating round of internship where I chose to work on Empathy- one of my favorite applications on the desktop!

I took the internships as a nudge for me to go ahead and try my luck diving into the huge pool of open-source developers I always wanted to be one of but was also a little scared of since there would have been no one to guide me or provide a walkthrough but after the internship, where I learnt equating page-turning software codes like page-turning a very interesting story-book which I always wanted to read, I understood what a blessing it was to have no one monitoring your moves! You hear of something interesting, you already know of something where you can apply this new interesting thing and VOILA! You have just created a new technology in your mind and you can create a brand new cool application based on it! All you have to do is to follow your instincts as you are totally FREE (as in freedom)!

First sight and a magnetic opportunity

So this very curious person, I, had witnessed a very powerful jumble of D-Bus and GIO - a  real-time communications service and framework named Telepathy, during her internship (back in 2011) which was perhaps some opportunist's, quite creative and apt exploitation of pending plans of DBusRemote with the added advantage of a hefty user base obtained from multiple presence and chat protocols it supports. I had no clue how I would make use of the new tool as I was glancing over this masterpiece, but I knew I wanted to know more of it!

Magically, roughly around that time, I was led to Robert Ancell's call for hackers to implement telepathy-networking for the GNOME-Games module he maintains. This required making use of telepathy's dbus-tube channels which when established with the remote contact would provide me a DBusConnection to communicate the way I want to with an application on a remote computer which your remote friend is logged in with. This technology in itself was amazing (yes, D-Bus-Remote!) and it was an awesome chance for me to satisfy my craving to explore Telepathy and to give a closer look to GNOME's nervous-system (the D-Bus messaging bus) and try my hand at a few other GNOME's latest technologies which wouldn't harm and only be additional assets to my skills.

Besides the things I have blogged about earlier, I learnt how to create libraries and use logging domains (which was very useful in debugging), write GSettings keys from multiple processes with dependency interactions in a controlled manner using delayed application, generating vapi files using gobject-introspection[1], use DBus messaging bus and export objects on it using GDBusConnection (in 3 different ways- low level method-calling and signal subscribing, higher level using Skeleton and Proxy objects, and the simplest of all, using Vala dbus-attributes which I could leverage, Vala being the language in which GlChess is mostly written and since I didn't want to create or manage another .vapi), creating asynchronous operations, creating GtkApplications from scratch and understanding their life-cycle, launching applications from code, making them handle command-line inputs in local and primary instances, parsing acceptable options using GOptionContext, creating telepathy-channels and making a tube-offer.

I hAcKeD into MissionControl (yay!!) - a daemon that is ALWAYS running on your favorite distribution with a well-known name of "org.freedesktop.Telepathy.MissionControl5" on the session bus and is the primary sense organ of the telepathy system. (If you got scared at this, rest assured, I am an ethical hacker as you'll notice if you find this interesting enough to read further!)

I also found a few bugs in telepathy-glib library, a GObject-based C binding for the Telepathy D-Bus API (which interfaces dbus-glib), which were generating a faulty telepathy-glib.vapi and thus hindering the Vala implementation I was working over, and made my debut commit (bfo bug# 55024) to it.


Opportunities exploited

I had seen that Empathy recognizes when a contact of mine has Vinagre installed on her system (and when I have Vino) and shows me an option to initiate a remote desktop session with her. I was impressed by the ability to know someone's capabilities just on the basis of what softwares (s)he has installed. Ideally I wanted something like that for games too. One should not have to run GlChess 24x7 or have it loaded in memory in order to receive chess-playing requests from online friends.

To confirm my use case, I peeked into MC-5 (mission-control-5 daemon) and found that on startup, the daemon looks for all d-bus activatable services (the ones with .service files installed in XDG_DATA_DIRS/d-bus-1/services/) and then checks which ones of those are activatable telepathy clients (ones with .client file installed in XDG_DATA_DIRS/telepathy/clients/) and registers them as activatable telepathy clients for the session. The capabilities of a contact are updated on all connection-managers at every recognition/modification of available activatable clients when MC calls.

This was cool and this was the basis behind how empathy-call works on the GNOME desktop. If you have empathy-call (UI application for handling telepathy's call channels and also a d-bus-activatable service) installed, your friends can always make a call to you which you can accept/reject. empathy-call is executed at runtime when after approval of an incoming call channel, the channel dispatcher in MC-5 wants to dispatch the channel to the call handler.

One fine day, I decided to try to fall into a need to have the above design implemented in GlChess. I knew this design would take a little more time and research on my part but I also knew that if not now, it would be implemented never! So, I started gauging the faesibility of this design and then I noticed that the design was flawed and aesthetically such an implementation of empathy-call shouldn't exist because there was no way for the advertiser of empathy-call to control his display of calling capability to his remote friends. He could only stop this advertisement by uninstalling empathy-call - that was inherently wrong. But that shouldn't stop me from implementing it and depriving users of such a cool feature! There must be a way created to make advertisement of an installed activatable service capability, to it's contacts, controlled by the user..  

(O-o-o Back in mind:  YAY!! I'll have more food for talks!)

The Hack: A roadblock cleared: That's what we have been waiting for...

...and it turned out, having this implemented wasn't very difficult! I already knew about GSettings by then and that I could easily read the serialized settings from multiple applications simultaneously. "Maybe something like a setting should suffice...", I thought to myself. I took a few Telepathy beans, a little GSettings setting sause, and shook them into a blender to create a recipe described in bfo bug# 53818. "EUREKA!!!", I yelled, while filing this feature-bug and necessity gave birth to invention! I am glad it received a positive and affirmative response from Telepathy developers and support from Robert with which GlChess is moving towards incorporating this highly sophesticated design approach to set an example and to begin a new trend for the next-generation desktop applications! It took me a registerful of notes to come uptil this level and atleast four charts to come out with this design. Developers will surely get smitten to this revolutionary design! Yeah, you are already allowed to think possibilities you can have with this!! Gnome-Shell doesn't implement it yet (it doesn't _really_ need it since it is already always running and loaded in memory throughout a user-session and wouldn't gain much with this apart from a possibility of an "advertise-call-capability" setting for example, which is also cool), nor do Empathy or Vinagre, but they are most likely the candidates which will benefit from it. This work, as a part of my telepathy-networking support suite of branches, is planned to be merged to GlChess master in 3.7 which will give it a chance to be thoroughly tested before being delivered to a release and will also provide many other desktop applications which are telepathy clients (like Empathy, GNOME Shell or Vinagre) a chance to implement this capability-advertisement-control concept, thereby finishing their implementations still-wanting attention (e.g. bgo bug# 576376) and GNOME users will experience a complete goodie package!!

Minor detours:

If you give a look at the WIP branch (or if you have already done that), you'll see that majority of the work was completed while some or the other freezes were in place. It turns out working on an intersection of multiple technologies is very tough when everything is unstable. Some of huge roadblocks and performance attenuators in my work this cycle were when I couldn't run empathy or any other application using folks after upgrading to Precise Pangola, without causing GNOME-Shell to freeze. Cause turned out to be showing signs of https://bugzilla.redhat.com/show_bug.cgi?id=760542, but on Ubuntu. I could work on Unity for a while but ultimately I had to test chat-handler launching for GNOME-Shell too and I was so badly suffering with it that I had made my mind to fix that bug (incase some of you saw me building shell out of my way and wondered what happened!). I had some folks messages in .xsession-errors just before the freeze and I hoped to get to the root cause using those. I built folks master. I tried to build GNOME-Shell master but I couldn't (no wonder - Mutter already broke its API in master) but to my relief, it turned out in the end that I could actually run my application with GNOME Shell 3.5.2 and Folks 0.7.1. But this happiness was also not long-lasting! Folks was changing very rapidly and I had to keep up with it. Games required Vala 0.15.1 and Folks was left behind, incompatible. Then folks made use of libgee-0.8 but the GNOME-Shell version I was working on made use of libgee-0.6 (which is named as gee-1.0, confusingly).

I was unable to run the newer GNOME-Shell due to: "Requiring Shell, version none: Requiring namespace 'Gee' version '0.8', but '1.0' is already loaded"

And everytime I tried to run the system-provided Gnome-Shell, I got a folks message: "Failed to reach quiescence normally (0 backends and 1 persona stores still haven't reached quiescence). Forcing IndividualAggregator quiescence due to reaching the timeout.", whenever my gnome-shell froze.

In the end, none of the folks applications ran on any window-manager including Gnome-Shell, Unity, Metacity and Compiz. To my relief, things got into a stabler mode closer to the end of the cycle and work started flourishing again... but I won't regret the delay caused by external factors since this is the prize which everyone had to pay, not just me, and this gap turned out to be a blessing where I could brainstorm and resolve a graver problem with telepathy-clients and come up with a design which would have otherwise taken a few more GNOME-years to materialize.



P.S.: This was a conceptual post.  You'll see more pictoral and diagrammatic posts in next blogging session. ;)
(Update: Added subheadings: will make locating keypoints easier in this so lo...ong post.)


Footnotes
[1] Games use a vapi file for a common support library written in C which is manually maintained by hand. I made a few additions to it but found manually editing of this file like a punishment so I generated the symbols myself and copied them to this handwritten vapi. The tool I used is secured here which may act as a live vapi generation tutorial.


Monday, April 16, 2012

GNOME.Asia Summit 2012 - Call for Participation

Hello all!

GNOME.Asia Summit is an annual conference for GNOME users and developers in Asia. The event focuses primarily on the GNOME desktop and devices that use GNOME, and also covers applications based on technologies underlying GNOME and GNOME development platform tools. It brings together the GNOME community in Asia to provide a forum for users, developers, foundation leaders, governments and businesses to discuss both the present technologies and future developments.


GNOME.Asia Summit 2012 will be the fifth Asian Summit to be held in Hong Kong and aimed at opening immense business opportunities for GNOME in Asia and create more awareness about GNOME in Asian countries.


Hong Kong Skyline



No waiting! Submit a talk now and add your name to the participants list.
If you have suggestions/ideas for BOFs/Workshops you wish to handle, send them in using the same web-form along with your details and an abstract of your idea or mail the details to organizers at asia-summit-list@gnome.org.

Know more!

Featured Post

interviewBit Medium: Palindrome Partitioning II

Problem Name:  Palindrome Partitioning II Problem Description : https://www.interviewbit.com/problems/palindrome-partitioning-ii/ Problem Ap...