1 /*
2  * application-database: A singelton managing desktop files and menus
3  *                       for installed applications
4  *
5  * Copyright 2012-2020 Stephan Haller <nomad@froevel.de>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20  * MA 02110-1301, USA.
21  *
22  *
23  */
24 
25 #ifndef __LIBXFDASHBOARD_APPLICATION_DATABASE__
26 #define __LIBXFDASHBOARD_APPLICATION_DATABASE__
27 
28 #if !defined(__LIBXFDASHBOARD_H_INSIDE__) && !defined(LIBXFDASHBOARD_COMPILATION)
29 #error "Only <libxfdashboard/libxfdashboard.h> can be included directly."
30 #endif
31 
32 #include <garcon/garcon.h>
33 
34 G_BEGIN_DECLS
35 
36 #define XFDASHBOARD_TYPE_APPLICATION_DATABASE				(xfdashboard_application_database_get_type())
37 #define XFDASHBOARD_APPLICATION_DATABASE(obj)				(G_TYPE_CHECK_INSTANCE_CAST((obj), XFDASHBOARD_TYPE_APPLICATION_DATABASE, XfdashboardApplicationDatabase))
38 #define XFDASHBOARD_IS_APPLICATION_DATABASE(obj)			(G_TYPE_CHECK_INSTANCE_TYPE((obj), XFDASHBOARD_TYPE_APPLICATION_DATABASE))
39 #define XFDASHBOARD_APPLICATION_DATABASE_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST((klass), XFDASHBOARD_TYPE_APPLICATION_DATABASE, XfdashboardApplicationDatabaseClass))
40 #define XFDASHBOARD_IS_APPLICATION_DATABASE_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE((klass), XFDASHBOARD_TYPE_APPLICATION_DATABASE))
41 #define XFDASHBOARD_APPLICATION_DATABASE_GET_CLASS(obj)		(G_TYPE_INSTANCE_GET_CLASS((obj), XFDASHBOARD_TYPE_APPLICATION_DATABASE, XfdashboardApplicationDatabaseClass))
42 
43 typedef struct _XfdashboardApplicationDatabase				XfdashboardApplicationDatabase;
44 typedef struct _XfdashboardApplicationDatabaseClass			XfdashboardApplicationDatabaseClass;
45 typedef struct _XfdashboardApplicationDatabasePrivate		XfdashboardApplicationDatabasePrivate;
46 
47 struct _XfdashboardApplicationDatabase
48 {
49 	/*< private >*/
50 	/* Parent instance */
51 	GObject									parent_instance;
52 
53 	/* Private structure */
54 	XfdashboardApplicationDatabasePrivate	*priv;
55 };
56 
57 struct _XfdashboardApplicationDatabaseClass
58 {
59 	/*< private >*/
60 	/* Parent class */
61 	GObjectClass							parent_class;
62 
63 	/*< public >*/
64 	/* Virtual functions */
65 	void (*menu_reload_required)(XfdashboardApplicationDatabase *self);
66 
67 	void (*application_added)(XfdashboardApplicationDatabase *self, GAppInfo *inAppInfo);
68 	void (*application_removed)(XfdashboardApplicationDatabase *self, GAppInfo *inAppInfo);
69 };
70 
71 /* Public API */
72 GType xfdashboard_application_database_get_type(void) G_GNUC_CONST;
73 
74 XfdashboardApplicationDatabase* xfdashboard_application_database_get_default(void);
75 
76 gboolean xfdashboard_application_database_is_loaded(const XfdashboardApplicationDatabase *self);
77 gboolean xfdashboard_application_database_load(XfdashboardApplicationDatabase *self, GError **outError);
78 
79 const GList* xfdashboard_application_database_get_application_search_paths(const XfdashboardApplicationDatabase *self);
80 
81 GarconMenu* xfdashboard_application_database_get_application_menu(XfdashboardApplicationDatabase *self);
82 GList* xfdashboard_application_database_get_all_applications(XfdashboardApplicationDatabase *self);
83 
84 GAppInfo* xfdashboard_application_database_lookup_desktop_id(XfdashboardApplicationDatabase *self,
85 																const gchar *inDesktopID);
86 
87 gchar* xfdashboard_application_database_get_file_from_desktop_id(const gchar *inDesktopID);
88 gchar* xfdashboard_application_database_get_desktop_id_from_path(const gchar *inFilename);
89 gchar* xfdashboard_application_database_get_desktop_id_from_file(GFile *inFile);
90 
91 G_END_DECLS
92 
93 #endif	/* __LIBXFDASHBOARD_APPLICATION_DATABASE__ */
94