Re: Finding .desktop file and application info



Hello,
Yes,  g_desktop_app_info_search() is exactly what I need.
I will test it later.

Thanks a lot for your help.
// Moma

tito-wolit <tito-wolit tiscali it> escreveu no dia segunda, 4/03/2019 à(s)
06:59:



On 3/3/19 9:53 PM, Osmo Antero wrote:
Hello Tito,
Muito obrigado.
Thank you, the call with "kde4-" worked fine.

However,  the "DesktopEntry" value from Amarok/DBus does not contain the
"kde4" part.
Please see the MRIS2-spec:
https://specifications.freedesktop.org/mpris-spec/latest/Media_Player.html#Property:DesktopEntry
My application cannot guess that it must include the "kde4" to get a
valid .desktop file.
I think g_desktop_app_info_new() should also browse all sub-directories,
but is does not.

Hi,

GDesktopAppInfo *app_info =
g_desktop_app_info_new("org.kde.amarok.desktop");
if (app_info == NULL )
        app_info = g_desktop_app_info_new("kde-org.kde.amarok.desktop");
if (app_info == NULL )
        app_info = g_desktop_app_info_new("kde2-org.kde.amarok.desktop");
if (app_info == NULL )
        app_info = g_desktop_app_info_new("kde3-org.kde.amarok.desktop");
if (app_info == NULL )
        app_info = g_desktop_app_info_new("kde4-org.kde.amarok.desktop");
if (app_info == NULL )
        app_info = g_desktop_app_info_new("kde5-org.kde.amarok.desktop");
else
        puts("can't find org.kde.amarok.desktop")

BTW: debian does set only:

XDG_DATA_DIRS=/usr/share/xfce4:/usr/local/share/:/usr/share/:/usr/share

maybe g_desktop_app_info_search ("amarok");
and then app_info = g_desktop_app_info_new(**strv);

g_desktop_app_info_search ()

gchar ***
g_desktop_app_info_search (const gchar *search_string);

Searches desktop files for ones that match search_string .

The return value is an array of strvs. Each strv contains a list of
applications that matched search_string with an equal score.
The outer list is sorted by score so that the first strv contains the
best-matching applications, and so on.
The algorithm for determining matches is undefined and may change at any
time.

Ciao,
Tito

One possible solutions is this:
The application should find the real location and path of
"org.kde.amarok.desktop".
The "locate" command does the same thing.
My app cannot call "locate" directly because it depends on "sudo
updatedb".
I will write my own routine that dives to usr/share/applications/ and
its sub folders.
This is my best shot !

Then the app can call:
GDesktopAppInfo *g_desktop_app_info_new_from_filename(const char
*filename);

My very old app is this: (the latest is v3.0.2)
https://launchpad.net/~audio-recorder

Thanks,
Obrigado e boa noite.
// Moma
Portugal




tito-wolit via gtk-app-devel-list <gtk-app-devel-list gnome org <mailto:
gtk-app-devel-list gnome org>> escreveu no dia domingo, 3/03/2019 à(s)
19:42:



    On 3/3/19 6:36 PM, Osmo Antero via gtk-app-devel-list wrote:
     > Hello,
     > I have an application that uses g_desktop_app_info_new() function
to
     > find GDesktopAppInfo.
     >
     > I just wonder why the g_desktop_app_info_new() FAILS to find the
     > GDesktopAppInfo if the .desktop file is in a sub directory
     > under usr/share/applications/.
     >
     > So this fails:
     > GDesktopAppInfo *app_info =
g_desktop_app_info_new("org.kde.amarok.desktop")

    hi,
    try:

    GDesktopAppInfo *app_info =
g_desktop_app_info_new("kde4-org.kde.amarok.desktop")

    ciao,
    Tito

     > If the "org.kde.amarok.desktop" file is located in:
     > /usr/share/applications/kde4/org.kde.amarok.desktop
     > This is the default location of Amarok player.
     > ---
     > Then I move the file "org.kde.amarok.desktop"  to
/usr/share/applications/.
     >
     > $ sudo mv /usr/share/applications/kde4/org.kde.amarok.desktop
     > /usr/share/applications/org.kde.amarok.desktop
     >
     > $ sudo updatedb
     > $ locate org.kde.amarok.desktop
     > /usr/share/applications/org.kde.amarok.desktop
     >
     > Now the call succeeds. It returns GDesktopAppInfo structure.
     > GDesktopAppInfo *app_info =
g_desktop_app_info_new("org.kde.amarok.desktop")
     >
     > Something is wrong, because the manual says that the desktop file
can stay
     > in a sub directory:
     >
     > """"
     > g_desktop_app_info_new ()
     > GDesktopAppInfo * g_desktop_app_info_new (const char *desktop_id);
     >
     > Creates a new GDesktopAppInfo based on a desktop file id.
     >
     > A desktop file id is the basename of the desktop file, including
the
     > .desktop extension. GIO is looking for a desktop file with this
name in the
     > applications subdirectories of the XDG data directories (i.e. the
     > directories specified in the XDG_DATA_HOME and XDG_DATA_DIRS
environment
     > variables). GIO also supports the prefix-to-subdirectory mapping
that is
     > described in the Menu Spec (i.e. a desktop id of kde-foo.desktop
will
     > match/usr/share/applications/kde/foo.desktop).
     > """"
     >
     > Just for info:
     > My application gets the "org.kde.amarok.desktop" name from Amarok
via the
     > MPRIS2 DBus-interface.  Please see "DesktopEntry" of
     >
https://specifications.freedesktop.org/mpris-spec/latest/Media_Player.html#Property:DesktopEntry
     >
     > Please educate me.
     >
     > Kindly
     >    Osmo Moma Antero
     >    Portugal
     >
    _______________________________________________
    gtk-app-devel-list mailing list
    gtk-app-devel-list gnome org <mailto:gtk-app-devel-list gnome org>
    https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



--
Sent from my PC, laptop or phone with Ubuntu-Linux.



-- 
Sent from my PC, laptop or phone with Ubuntu-Linux.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]