1 | /* |
2 | * Copyright © 2011 Canonical Limited |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Lesser General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2 of the licence, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Lesser General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Lesser General Public |
15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
16 | * |
17 | * Author: Ryan Lortie <desrt@desrt.ca> |
18 | */ |
19 | |
20 | #ifndef __GTK_ACTION_MUXER_H__ |
21 | #define __GTK_ACTION_MUXER_H__ |
22 | |
23 | #include <gio/gio.h> |
24 | #include "gtkwidget.h" |
25 | |
26 | G_BEGIN_DECLS |
27 | |
28 | #define GTK_TYPE_ACTION_MUXER (gtk_action_muxer_get_type ()) |
29 | #define GTK_ACTION_MUXER(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ |
30 | GTK_TYPE_ACTION_MUXER, GtkActionMuxer)) |
31 | #define GTK_IS_ACTION_MUXER(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ |
32 | GTK_TYPE_ACTION_MUXER)) |
33 | |
34 | typedef struct _GtkWidgetAction GtkWidgetAction; |
35 | typedef struct _GtkActionMuxer GtkActionMuxer; |
36 | |
37 | struct _GtkWidgetAction |
38 | { |
39 | GtkWidgetAction *next; |
40 | |
41 | char *name; |
42 | GType owner; |
43 | |
44 | const GVariantType *parameter_type; |
45 | GtkWidgetActionActivateFunc activate; |
46 | |
47 | const GVariantType *state_type; |
48 | GParamSpec *pspec; |
49 | }; |
50 | |
51 | GType gtk_action_muxer_get_type (void); |
52 | GtkActionMuxer * gtk_action_muxer_new (GtkWidget *widget); |
53 | |
54 | void gtk_action_muxer_insert (GtkActionMuxer *muxer, |
55 | const char *prefix, |
56 | GActionGroup *action_group); |
57 | |
58 | void gtk_action_muxer_remove (GtkActionMuxer *muxer, |
59 | const char *prefix); |
60 | GActionGroup * gtk_action_muxer_find (GtkActionMuxer *muxer, |
61 | const char *action_name, |
62 | const char **unprefixed_name); |
63 | GActionGroup * gtk_action_muxer_get_group (GtkActionMuxer *muxer, |
64 | const char *group_name); |
65 | GtkActionMuxer * gtk_action_muxer_get_parent (GtkActionMuxer *muxer); |
66 | |
67 | void gtk_action_muxer_set_parent (GtkActionMuxer *muxer, |
68 | GtkActionMuxer *parent); |
69 | |
70 | /* GActionGroup equivalent api */ |
71 | gboolean gtk_action_muxer_query_action (GtkActionMuxer *muxer, |
72 | const char *action_name, |
73 | gboolean *enabled, |
74 | const GVariantType **parameter_type, |
75 | const GVariantType **state_type, |
76 | GVariant **state_hint, |
77 | GVariant **state); |
78 | void gtk_action_muxer_activate_action (GtkActionMuxer *muxer, |
79 | const char *action_name, |
80 | GVariant *parameter); |
81 | void gtk_action_muxer_change_action_state (GtkActionMuxer *muxer, |
82 | const char *action_name, |
83 | GVariant *state); |
84 | gboolean gtk_action_muxer_has_action (GtkActionMuxer *muxer, |
85 | const char *action_name); |
86 | char ** gtk_action_muxer_list_actions (GtkActionMuxer *muxer, |
87 | gboolean local_only); |
88 | |
89 | /* api for class actions */ |
90 | void gtk_action_muxer_action_enabled_changed (GtkActionMuxer *muxer, |
91 | const char *action_name, |
92 | gboolean enabled); |
93 | void gtk_action_muxer_action_state_changed (GtkActionMuxer *muxer, |
94 | const char *action_name, |
95 | GVariant *state); |
96 | void gtk_action_muxer_connect_class_actions (GtkActionMuxer *muxer); |
97 | |
98 | /* api for accels */ |
99 | void gtk_action_muxer_set_primary_accel (GtkActionMuxer *muxer, |
100 | const char *action_and_target, |
101 | const char *primary_accel); |
102 | const char * gtk_action_muxer_get_primary_accel (GtkActionMuxer *muxer, |
103 | const char *action_and_target); |
104 | |
105 | /* No better place for these... */ |
106 | char * gtk_print_action_and_target (const char *action_namespace, |
107 | const char *action_name, |
108 | GVariant *target); |
109 | char * gtk_normalise_detailed_action_name (const char *detailed_action_name); |
110 | |
111 | G_END_DECLS |
112 | |
113 | #endif /* __GTK_ACTION_MUXER_H__ */ |
114 | |