Initial check-in to git.
[XDGStart.git] / src / xdgautostart.h
blob2761b0c2fc128d20283507c1ab589846f761cdff
1 /*
2 * By Tony Houghton, <h@realh.co.uk>.
3 */
5 #ifndef XDGAUTOSTART_H
6 #define XDGAUTOSTART_H
8 #include <glib.h>
10 typedef struct {
11 char * name;
12 char * pathname;
13 char * basename;
14 gboolean deletable;
15 gboolean savable;
16 char * exec;
17 char * path;
18 gboolean terminal;
19 char * try_exec;
20 char ** only_show_in;
21 char ** not_show_in;
22 GKeyFile * kf;
23 } DesktopEntry;
25 /* Returns FALSE if invalid; you should then call desktop_entry_free/delete */
26 gboolean desktop_entry_load(DesktopEntry *, const char *pathname,
27 const char *basename, gboolean keep_keyfile, gboolean savable);
29 /* Fills in some of the fields from the (already open) keyfile */
30 void desktop_entry_read_keyfile(DesktopEntry *);
32 /* Doesn't free the top-level struct */
33 void desktop_entry_free(DesktopEntry *);
35 /* Does free the top-level struct */
36 void desktop_entry_delete(DesktopEntry *);
38 /* Closes keyfile once loaded (read-only) */
39 DesktopEntry *desktop_entry_new(const char *pathname, const char *basename,
40 gboolean savable);
42 /* desktop_entry_new() can be used as a constructor */
43 typedef DesktopEntry *(DesktopEntryConstructor)
44 (const char *pathname, const char *basename, gboolean savable);
46 /* Whether (copy of) s is in v */
47 gboolean desktop_entry_str_in_strv(char **v, const char *s);
49 /* Returns whether entry should be started in environ
50 * based on OnlyShowIn and NotShowIn */
51 gboolean desktop_entry_get_show_in_environ(const DesktopEntry *,
52 const char *environ);
54 inline static gboolean desktop_entry_get_show_in_rox(const DesktopEntry *de)
56 return desktop_entry_get_show_in_environ(de, "ROX");
59 /* Also checks Exec and TryExec */
60 gboolean desktop_entry_can_start_in_rox(const DesktopEntry *);
63 /* Scans XDG autostart directories for desktop files;
64 * ctor should be similar to desktop_entry_new() */
65 GList *get_desktop_entries(DesktopEntryConstructor ctor);
67 inline static gboolean str_is_empty(const char *s)
69 return !s || !s[0];
72 gboolean str_v_is_empty(char **sv);
74 #endif /* XDGAUTOSTART_H */