Commit Graph

172 Commits

Author SHA1 Message Date
Daniel Mustieles
078dbda148 Updated FSF's address 2014-01-31 14:31:55 +01:00
Rico Tzschichholz
60cca82c9d gdesktopinfo: Fix typo in "Since" annotation of has_key 2014-01-13 12:33:35 +01:00
Martin Pitt
e6c86d58f2 gdesktopappinfo: Add missing annotations
Add missing (allow-none) annotations to
g_desktop_app_info_launch_uris_as_manager(). Tested with

  python -c "from gi.repository import GLib, Gio; Gio.DesktopAppInfo.new('gcalctool.desktop').launch_uris_as_manager([], None, GLib.SpawnFlags.SEARCH_PATH|GLib.SpawnFlags.STDOUT_TO_DEV_NULL, None, None, None, None)"

which is necessary to do a launch_uris() without leaking stdout.

https://launchpad.net/bugs/1259721
2013-12-11 13:17:10 +01:00
Florian Müllner
2fb8901b64 gdesktopappinfo: Rank Keywords matches higher than GenericName
It makes sense to match on GenericName in case an application does
not provide any keywords, but the Keywords field has been added
to explicitly support the search case, while GenericName was used
to be displayed in menus, so it makes more sense to consider
Keywords more (or equally) relevant for search.

https://bugzilla.gnome.org/show_bug.cgi?id=711640
2013-11-13 16:54:02 +01:00
Ryan Lortie
3d32d5359a Add g_desktop_app_info_search()
The first time this function is called we load all of the keyfiles in
the directory, ignoring the 'Hidden' ones and build an index out of the
interesting fields using g_str_tokenize_and_fold().

We do prefix matching on the tokens to find relevent desktop files.

Right now this is implemented as a hashtable that we iterate over,
checking prefixes on each token.  This could possibly be sped up by
creating an array, but it's already pretty fast...

https://bugzilla.gnome.org/show_bug.cgi?id=711557
2013-11-07 12:41:27 -05:00
Ryan Lortie
e55d33edc1 Add GAppInfoMonitor
This is a simple object that emits a "change" signal when the installed
applications may have changed in some way.

https://bugzilla.gnome.org/show_bug.cgi?id=711556
2013-11-06 11:26:53 -05:00
Ryan Lortie
86ce3bf48e gdesktopappinfo: keep a list of files in the dirs
In each DesktopFileDir, store a list of desktop files for that
directory.  This speeds up opening desktop files by name because we can
skip statting in directories that we know don't have the file and also
speeds up _get_all() because we can avoid enumeration.

This also improves our support for dealing with names like
'kde4/kate.desktop' (equivalent to kde4-kate.desktop) since we find out
about all of these files are the start and don't need to guess about
which '-' to change to a '/'.  It also means that we can easily deal
with more than one level of such prefixes.

We use a file monitor to watch for changes, invalidating our lists when
we notice them.

https://bugzilla.gnome.org/show_bug.cgi?id=711520
2013-11-06 10:56:25 -05:00
Ryan Lortie
e0ffd5c184 appinfo: Don't try DBusActivatable with load_from_keyfile
We can't get the name of the filename, so we can't determine the application
ID.  We'll have to fallback on Exec= for this case.

https://bugzilla.gnome.org/show_bug.cgi?id=709326
2013-10-04 12:19:03 -04:00
Ryan Lortie
c8e1dbb106 gdesktopappinfo: Large-scale whitespace fixup
Fix up a lot of whitespace issues in this file since we're about to do
some pretty serious rewriting here anyway...

Add some fold markers while we're at it.
2013-10-03 10:40:25 -04:00
Ryan Lortie
b0601e7558 gdesktopappinfo: rework search path
Change the search path to be a global array of 'DesktopFileDir' structures and
change the 'get' function to an 'ensure' function.

This is just a straight-up refactor.  Future patches will expand the
DesktopFileDir structure.
2013-10-03 10:40:25 -04:00
Ryan Lortie
5e59ab8e8c gdesktopappinfo: remove global_defaults_cache
...and some related functions.

This variable is also used for nothing at all.
2013-10-03 10:40:25 -04:00
Ryan Lortie
b95ef4aad4 gdesktopappinfo: remove should_ping_mime_monitor
This variable is used for nothing...
2013-10-03 10:40:25 -04:00
Bastien Nocera
2d8e5ef81e gdesktopappinfo: Call g_file_get_path() on demand
Rather than always calling out to g_file_get_path() (which
might block, whatever the documentation might say), postpone
the call until we actually need it.

https://bugzilla.gnome.org/show_bug.cgi?id=708753
2013-09-27 09:52:57 +02:00
Daniel Svensson
8a1b553728 gdesktopappinfo: Add missing return value 2013-07-30 18:20:44 -04:00
Ryan Lortie
9ec8ab62b2 GDesktopAppInfo: remove note about OnlyShowIn
A previous version of the patch had OnlyShowIn support for desktop file
actions.  This was removed from the spec and the patch rewritten, but
this bit of documentation slipped through.  Remove it.
2013-07-11 13:04:23 -04:00
Ryan Lortie
6dc5c118e4 Implement the Desktop Action specification
For some time, the desktop file specification has supported "additional
application actions".  This is intended to allow for additional methods
of starting an app, such as a mail client having a "Compose New Message"
action that brings up the compose window instead of the folder list.

This patch adds support for this with a relatively minimal API.

In the case that the application is a GApplication and DBusActivatable,
desktop actions are translated into GActions that have been added to the
application with g_action_map_add_action().  This more or less closes
the loop on being able to activate an application with an action
invocation (instead of 'activate').

https://bugzilla.gnome.org/show_bug.cgi?id=664444
2013-07-11 12:48:08 -04:00
Ryan Lortie
afc8b1020a GDesktopAppInfo: support DBusActivatable
Support the sender-side of the freedesktop application specification for
cases that we find 'DBusActivatable=true' in the desktop file.

https://bugzilla.gnome.org/show_bug.cgi?id=699259
2013-06-07 18:36:55 -04:00
Tim Lunn
daf7f56491 gio: fix small leak
https://bugzilla.gnome.org/show_bug.cgi?id=699361
2013-05-01 11:15:13 +10:00
Jasper St. Pierre
c0af442909 gdesktopappinfo: Allow getting the desktop ID from the filename 2013-04-21 00:09:47 -04:00
Cosimo Cecchi
f641699299 desktopappinfo: check whether the specified executable is valid
Before declaring the desktop file as valid, make sure the referenced
application actually exists in path and the commandline is not
malformed.

https://bugzilla.gnome.org/show_bug.cgi?id=675333
2013-03-04 14:40:36 -05:00
Colin Walters
f398bec5bc Add g_close(), use it
There are two benefits to this:

1) We can centralize any operating system specific knowledge of
   close-vs-EINTR handling.  For example, while on Linux we should never
   retry, if someone cared enough later about HP-UX, they could come by
   and change this one spot.
2) For places that do care about the return value and want to provide
   the caller with a GError, this function makes it convenient to do so.

Note that gspawn.c had an incorrect EINTR loop-retry around close().

https://bugzilla.gnome.org/show_bug.cgi?id=682819
2013-01-29 09:46:04 -05:00
Matthias Clasen
bace1822d7 GAppLaunchContext: make it possible ot get the effective startup id
gnome-session needs to know the startup id that was given to
a started app; this was not available via GAppLaunchContext.
This commit adds a ::launched signal to get this information.
At the same time, turn the launch_failed vfunc into a signal
as well.

https://bugzilla.gnome.org/show_bug.cgi?id=688497
2012-11-21 21:20:25 -05:00
Matthias Clasen
4adbc7aa42 GDesktopAppInfo: add enough api to make autostart implementable
gnome-session still uses EggDesktopFile, since GDesktopAppInfo is
missing a handful of APIs that are needed to implement the
autostart spec. This patch adds the minimum that is required.

https://bugzilla.gnome.org/show_bug.cgi?id=688497
2012-11-21 21:12:45 -05:00
Matthias Clasen
344066e0c1 Fix gio docs 2012-09-23 02:18:56 -04:00
Dan Winship
fa58cef826 GDesktopAppInfo: fix leaks
g_desktop_app_info_ensure_saved() was leaking the file contents.

_g_desktop_app_info_launch_uris_internal() was leaking the session bus
on error.

https://bugzilla.gnome.org/show_bug.cgi?id=682560
2012-09-03 08:36:10 -04:00
Colin Walters
f7abd3ce13 Add g_spawn_check_exit_status()
Many (if not "almost all") programs that spawn other programs via
g_spawn_sync() or the like simply want to check whether or not the
child exited successfully, but doing so requires use of
platform-specific functionality and there's actually a fair amount of
boilerplate involved.

This new API will help drain a *lot* of mostly duplicated code in
GNOME, from gnome-session to gdm.  And we can see that some bits even
inside GLib were doing it wrong; for example checking the exit status
on Unix, but ignoring it on Windows.

https://bugzilla.gnome.org/show_bug.cgi?id=679691
2012-07-10 18:03:56 -04:00
Alexander Larsson
c35106fcc4 Fix the mimetype default fix
We need to ignore the defaults.list item only when there
was a mimetype handler found in a previous mimetype, not
if one was found for the same mimetype as the one that
is listed in defaults.list (same for the new-style defaults).
2012-06-28 15:38:06 +02:00
Alexander Larsson
f14c0112d0 Fix default app lookup wrt parent types and defaults.list
There was an issue when looking up the default handler
for a type where a supertype was listed in defaults.list.
We would pick the default for the parent type even if
there was a handler for the more specific type.

In the case of the new-style defaults marking (
"Default Applications" in mimeapps.list) we were already
checking for a more specific handler befor using a default,
but we also need to do a similar check for the defaults.list
case.

https://bugzilla.gnome.org/show_bug.cgi?id=678944
2012-06-28 15:05:03 +02:00
Holger Berndt
0e6d9df35c Document that g_app_info_create_from_commandline() does unquoting according to fd.o
https://bugzilla.gnome.org/show_bug.cgi?id=676277
2012-05-18 15:20:40 +02:00
Giovanni Campagna
0417ddab6f GAppInfo: add a mechanism to query supported content types
This essentially adds an accessor for the MimeType field in desktop files,
to retrieve the list of all mime types supported by an application.
The interface though is part of GAppInfo, so it could be implemented
in the future by other backends.

https://bugzilla.gnome.org/show_bug.cgi?id=674111
2012-05-16 12:42:12 +02:00
Debarshi Ray
3f816dc5d1 GAppInfo: overwrite the DISPLAY only if it is set in the launch context
If the launch context is a GAppLaunchContext, and not a
GdkAppLaunchContext, then g_app_launch_context_get_display will return
NULL because the get_display virtual method is undefined. The DISPLAY
might still be inherited from the parent process, in which case
overwriting it with NULL breaks the launch.

This is a regression introduced in:
de834bed30

Fixes: https://bugzilla.gnome.org/672786
2012-04-26 23:10:41 +02:00
Giovanni Campagna
bb7f3e0cbd GDesktopAppInfo: add an accessor for StartupWMClass
Components using GIO to do window to application matching can
use that field to retrieve potential candidates.

https://bugzilla.gnome.org/show_bug.cgi?id=673659
2012-04-14 02:44:25 +02:00
Matthias Clasen
d0b429af48 Revert "GDesktopAppInfo: add an accessor for StartupWMClass"
This reverts commit 3ccc4cf91d.
2012-04-06 19:15:53 -04:00
Giovanni Campagna
3ccc4cf91d GDesktopAppInfo: add an accessor for StartupWMClass
Components using GIO to do window to application matching can
use that field to retrieve potential candidates.

https://bugzilla.gnome.org/show_bug.cgi?id=673659
2012-04-07 00:22:02 +02:00
Dieter Verfaillie
8e740f726f Fix malformed GTK-Doc comment blocks: add missing colons.
Found these thanks to improved gobject-introspection GTK-Doc
comment block/annotation parser from:
https://bugzilla.gnome.org/show_bug.cgi?id=672254

https://bugzilla.gnome.org/show_bug.cgi?id=673385
2012-04-05 10:23:39 -03:00
Dan Winship
ca05902a58 Add G_GNUC_BEGIN/END_IGNORE_DEPRECATIONS
Add new macros to disable -Wdeprecated-declarations around a piece of
code, using the C99 (and GNU89) _Pragma() operator. Replace the
existing use of #pragma for this in gio, and suppress the warnings in
gvaluearray.c as well.

https://bugzilla.gnome.org/show_bug.cgi?id=669671
2012-02-15 09:54:38 -05:00
Matthias Clasen
9fe3d34ae3 Move pragmas out of function body
It seems that older gcc does not like pragmas inside functions.
2012-01-30 15:26:15 -05:00
Matthias Clasen
bdd0aada62 Silence another deprecation warning 2012-01-30 14:21:03 -05:00
Michael Terry
382341dd99 gdesktopappinfo: Fix gtk-doc to mention Keywords not X-GNOME-Keywords
https://bugzilla.gnome.org/show_bug.cgi?id=667285
2012-01-05 11:19:22 -05:00
Michael Terry
31c3082e19 gdesktopappinfo: Avoid crash by NULL-ing data.pid_envvar before launch
https://bugzilla.gnome.org/show_bug.cgi?id=667279
2012-01-04 13:08:56 -05:00
Javier Jardón
928d2cea61 gio/*: Use g_list_free_full() convenience function 2012-01-03 16:53:47 +01:00
Florian Müllner
f59acb55c1 gdesktopappinfo: Use "Keywords" instead of "X-GNOME-Keywords"
The field has now been standardized, so drop the prefix.
2011-12-19 15:26:30 +01:00
Matthias Clasen
5896808e8c GIO: Don't use G_DISABLE_DEPRECATED for functions 2011-11-03 00:16:41 -04:00
Cosimo Cecchi
3569af4af1 desktop-app-info: annotate g_desktop_app_info_get_keywords()
https://bugzilla.gnome.org/show_bug.cgi?id=662096
2011-10-19 17:27:21 -04:00
Dan Winship
de834bed30 GAppLaunchContext: add environment-manipulating functions
Add functions for manipulating the environment under which a
GAppLaunchContext will launch its children, to avoid thread-related
bugs with using setenv() directly.

FIXME: win32 side isn't implemented yet

https://bugzilla.gnome.org/show_bug.cgi?id=659326
2011-10-15 17:30:55 -04:00
Florian Müllner
1ed88f0615 desktop-app-info: Add support for X-GNOME-Keywords
With search gaining traction as being the preferred way to locate
applications, the existing .desktop file fields meant for browsing
often produce insufficient results.
gnome-control-center introduced a custom X-GNOME-Keywords field for
that purpose, which we plan to support in gnome-shell as well.

https://bugzilla.gnome.org/show_bug.cgi?id=661763
2011-10-14 23:30:21 +02:00
Matthias Clasen
5156d1b2d4 Prevent data loss in gdesktopappinfo.c
Don't loose the content of mimeapps.list when it doesn't contain
a [Added Associations] group. Pointed out by Alexander Larsson.

https://bugzilla.gnome.org/show_bug.cgi?id=660130
2011-09-29 23:42:58 -04:00
Ryan Lortie
104ea17125 GDesktopAppInfo: simplify how defaults work
Previously, we took the default application for a particular mimetype
from the system and copied it into the user's configuration as the
default there.

Instead of doing that we leave the user's default unset, and at time of
use, if the user has no explicitly-set default value, we use the system
default.

This avoids complicated situations where inappropriate applications were
being set as the default in the user's configuration.

https://bugzilla.gnome.org/show_bug.cgi?id=658188
2011-09-26 16:54:24 -04:00
Matthias Clasen
2d44a45b6b GDesktopAppInfo: Improve docs 2011-09-12 01:56:45 -04:00
Matthias Clasen
05342d0a93 Fix formatting in a doc comment 2011-09-12 01:49:01 -04:00