1 /*
2  * vala-panel-appmenu
3  * Copyright (C) 2018 Konstantin Pugin <ria.freelander@gmail.com>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef ITEM_H
20 #define ITEM_H
21 
22 #include <gio/gio.h>
23 #include <stdbool.h>
24 
25 #include "dbusmenu-interface.h"
26 #include "definitions.h"
27 #include "model.h"
28 
29 G_BEGIN_DECLS
30 
31 typedef struct
32 {
33 	int section_num;
34 	int place;
35 	u_int32_t id;
36 	GActionGroup *ref_action_group;
37 	// FIXME: Cannot have activatable submenu item.
38 	GAction *ref_action;
39 	GHashTable *attrs;
40 	GHashTable *links;
41 	DBusMenuActionType action_type;
42 	bool enabled;
43 	bool toggled;
44 	gpointer magic;
45 } DBusMenuItem;
46 
47 G_GNUC_INTERNAL DBusMenuItem *dbus_menu_item_new(u_int32_t id, DBusMenuModel *parent_model,
48                                                  GVariant *props);
49 G_GNUC_INTERNAL DBusMenuItem *dbus_menu_item_new_first_section(u_int32_t id,
50                                                                GActionGroup *action_group);
51 
52 G_GNUC_INTERNAL void dbus_menu_item_free(gpointer data);
53 
54 G_GNUC_INTERNAL bool dbus_menu_item_update_enabled(DBusMenuItem *item, bool enabled);
55 
56 G_GNUC_INTERNAL bool dbus_menu_item_update_props(DBusMenuItem *item, GVariant *props);
57 
58 G_GNUC_INTERNAL bool dbus_menu_item_remove_props(DBusMenuItem *item, GVariant *props);
59 
60 G_GNUC_INTERNAL bool dbus_menu_item_compare_immutable(DBusMenuItem *a, DBusMenuItem *b);
61 
62 G_GNUC_INTERNAL bool dbus_menu_item_copy_attributes(DBusMenuItem *src, DBusMenuItem *dst);
63 
64 G_GNUC_INTERNAL bool dbus_menu_item_is_firefox_stub(DBusMenuItem *item);
65 
66 G_GNUC_INTERNAL void dbus_menu_item_copy_submenu(DBusMenuItem *src, DBusMenuItem *dst,
67                                                  DBusMenuModel *parent);
68 
69 G_GNUC_INTERNAL void dbus_menu_item_generate_action(DBusMenuItem *item, DBusMenuModel *parent);
70 
71 G_GNUC_INTERNAL void dbus_menu_item_preload(DBusMenuItem *item);
72 
73 G_GNUC_INTERNAL int dbus_menu_item_id_compare_func(const DBusMenuItem *a, gconstpointer b,
74                                                    gpointer user_data);
75 
76 G_GNUC_INTERNAL int dbus_menu_item_compare_func(const DBusMenuItem *a, const DBusMenuItem *b,
77                                                 gpointer user_data);
78 
79 G_END_DECLS
80 
81 #endif // ITEM_H
82