Monday, January 21, 2013

Bug fixed!


For the last two day I spent a lot of time trying to understand what does the source code of specified files and trying to figure out how to fix the auto-parenting problem. However, I am not able to prove my theory that the "Enter a conferece server" dialog is beiing auto-parented by the wrong window. I have tracked the problem to the very low level, to the implementation of the jabber protocol, from which the problematic dialog is being rised. But now there are so many function calls and so many branches that I got a little confused.

"If we knew what it was we were doing, it would not
 be called research, would it?"
    -- Albert Einstein -- 

I tried some coding without complete understanding of the hiererchy of the windows. And I succed. Albert Einstein was a wise man. I have modified the code so that I got the desired behaviour of the dialog windows. All the problems were solved by two additional lines of code and encapsulate call of one function so I could pass the parent window as a parameter (the first function is the original one; the second is my modification, which are in bold and underlined):

void pidgin_roomlist_dialog_show_with_account(PurpleAccount *account)
{
    PidginRoomlistDialog *dialog = pidgin_roomlist_dialog_new_with_account(account);

    if (!dialog)
        return;

    list_button_cb(GTK_BUTTON(dialog->list_button), dialog);
}


void
pidgin_roomlist_dialog_show_with_account_dialog(GtkWidget*parent_dialog,PurpleAccount *account)
{
    PidginRoomlistDialog *dialog = pidgin_roomlist_dialog_new_with_account(account);

    if (!dialog)
        return;

    gtk_window_set_transient_for(GTK_WINDOW(dialog->window),GTK_WINDOW(parent_dialog)); 

    gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog->window), TRUE);

    list_button_cb(GTK_BUTTON(dialog->list_button), dialog);
}

Actually, for the fix of the orriginal problem only the gtk_window_set_transient_for() is required. The function gtk_window_set_destroy_with_parent fixes the problem, that when the parent window is closed("Join a chat") the window "Roomlist" stays visible and when the join a chat procedure is repeated multiple times, mulitple windows "Roomlist" stay open. The function destroyes the "Roomlist" window when the parent window "Join a chat" is destroyed.

No comments:

Post a Comment