! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Default application not respected with glib >= 2.41
Status:
RESOLVED: FIXED
Severity:
critical

Comments

Description Evangelos Foutras 2014-10-02 19:46:51 CEST
Beginning with glib >= 2.41, g_app_info_get_all_for_type() no longer puts the default application in front of the list. (See glib commit 6fd5a8c. [1])

Thunar seems to depend on the removed behavior to correctly pick the default application for the selected file(s), and thus needs to be adjusted to use g_app_info_get_default_for_type() instead.

I also found a Debian bug report about this with reproduction details. [2]

[1] https://git.gnome.org/browse/glib/commit/?id=6fd5a8c
[2] https://bugs.debian.org/763726
Comment 1 Evangelos Foutras 2014-10-03 06:34:14 CEST
Created attachment 5675 
Fix "Open With" default app with glib >= 2.41

Here's a quick and dirty fix; maybe someone else can come up with a more elegant solution. :)
Comment 2 Evangelos Foutras 2014-10-03 06:45:18 CEST
Created attachment 5676 
Fix "Open With" default app with glib >= 2.41

(I had to fix that "frond" typo. :3)
Comment 3 Guido Berhoerster 2014-10-14 13:07:50 CEST
Created attachment 5690 
ensure thunar_file_list_get_applications() has the default application as the first element of the returned list

Nice find. Since thunar_file_list_get_applications() and its only consumer thunar_launcher_update_idle() are the only places that expect g_app_info_get_all_for_type() to have the default application as the first element, I don't think it's necessary to expose something like thunar_g_app_info_get_all_for_type(). Attached is a slightly revised patch that inlines the list reordering into thunar_file_list_get_applications().
Comment 4 Evangelos Foutras 2014-10-14 22:04:48 CEST
(In reply to Guido Berhoerster from comment #3)
> Created attachment 5690 
> ensure thunar_file_list_get_applications() has the default application as
> the first element of the returned list
> 
> Nice find. Since thunar_file_list_get_applications() and its only consumer
> thunar_launcher_update_idle() are the only places that expect
> g_app_info_get_all_for_type() to have the default application as the first
> element, I don't think it's necessary to expose something like
> thunar_g_app_info_get_all_for_type(). Attached is a slightly revised patch
> that inlines the list reordering into thunar_file_list_get_applications().

I agree that this is the preferred way to fix this. I tested your patch and it works fine (as expected).

Please note that submitting a patch created using 'git format-patch' with proper commit message would ease the job of whoever commits this. It would also include proper credit for your work once it's applied. :)
Comment 5 Norbert Preining 2014-10-30 08:42:21 CET
Hi everyone, 

I just tried the patch from the second attachment (from Guido) on Debian/sid, but it does not fix everything.

The selected application is now used, but changing the default application is still broken. 

In particular, right clicking on an item I see
   Open with AAAAA
but when I right-click -> Properties and check the 
   Open with 
droplist, then there is a different value written.

It seems that another place needs fixing, or do I need to use *both* of the attached patches in this bug?

Thanks

Norbert
Comment 6 Guido Berhoerster 2014-10-30 09:43:48 CET
(In reply to Norbert Preining from comment #5)
> I just tried the patch from the second attachment (from Guido) on
> Debian/sid, but it does not fix everything.
> 
> The selected application is now used, but changing the default application
> is still broken. 
> 
> In particular, right clicking on an item I see
>    Open with AAAAA
> but when I right-click -> Properties and check the 
>    Open with 
> droplist, then there is a different value written.
> 
> It seems that another place needs fixing,

I cannot reproduce that here and I don't see how this is possible, the combobox in the properties dialog uses a ThunarChooserButton which calls g_app_info_get_default_for_type() to preselect the default application. So the preselected application in the properties dialog should always be correct and reflect what ~/.config/mimeapps.list contains. The context menu is what should be fixed by this patch (by calling the g_app_info_get_default_for_type() as the combobox does). Have you properly applied the patch before building thunar and are you sure you are actually running the rebuilt version?
If yes, then please provide some more detailed information on how to reproduce this. In particular, temporarily remove ~/.config/mimeapps.list, log out and back in, change the default association of some filetype and then report what the context menu shows, what the property dialog combobox has preselected and what the contents of ~/.config/mimeapps.list are and what your glib version is.

> or do I need to use *both* of the
> attached patches in this bug?

No, the second one is just a refactored version of the first one.
Comment 7 Norbert Preining 2014-10-30 09:47:55 CET
Ok, sorry for the noise.

I killed Thunar and restarted it, but that seems to not have sufficed.

After logging out of xfce and logging in again I now see the proper behaviour.

I will go ahead and prepare an NMU for Debian's thunar.

Thanks
Comment 8 Yves-Alexis Perez editbugs 2014-10-30 10:31:36 CET
(In reply to Norbert Preining from comment #7)
> I will go ahead and prepare an NMU for Debian's thunar.

You don't really have to, you know. But it'd help to have it committed to master and stable branches first.
Comment 9 Eric Koegel editbugs 2014-10-30 18:36:12 CET
Created attachment 5715 
Guido's patch

This is Guido's patch in a git am-able format.
Comment 10 Guido Berhoerster 2014-10-30 18:40:12 CET
(In reply to Eric Koegel from comment #9)
> Created attachment 5715 
> Guido's patch
> 
> This is Guido's patch in a git am-able format.

Thanks, but Evangelos should be credited for investigating and fixing this, I only did some minor refactoring.
Comment 11 Evangelos Foutras 2014-10-30 18:52:35 CET
(In reply to Guido Berhoerster from comment #10)
> (In reply to Eric Koegel from comment #9)
> > Created attachment 5715 
> > Guido's patch
> > 
> > This is Guido's patch in a git am-able format.
> 
> Thanks, but Evangelos should be credited for investigating and fixing this,
> I only did some minor refactoring.

Nah, your patch is the proper way to fix this so credit should go to you.

I'm fine with applying the latest patch as-is (the one attached by Eric).
Comment 12 Simon Steinbeiss editbugs 2014-11-01 19:41:14 CET
Pushed to master, thanks for the patch, testing and review.

Bug #11212

Reported by:
Evangelos Foutras
Reported on: 2014-10-02
Last modified on: 2014-11-01

People

Assignee:
Jannis Pohlmann
CC List:
9 users

Version

Attachments

Additional information