1/*
2 * Copyright © 2010 Codethink 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_APPLICATION_H__
21#define __GTK_APPLICATION_H__
22
23#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
24#error "Only <gtk/gtk.h> can be included directly."
25#endif
26
27#include <gtk/gtkwidget.h>
28#include <gio/gio.h>
29
30G_BEGIN_DECLS
31
32#define GTK_TYPE_APPLICATION (gtk_application_get_type ())
33#define GTK_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_APPLICATION, GtkApplication))
34#define GTK_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_APPLICATION, GtkApplicationClass))
35#define GTK_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_APPLICATION))
36#define GTK_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_APPLICATION))
37#define GTK_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_APPLICATION, GtkApplicationClass))
38
39typedef struct _GtkApplication GtkApplication;
40typedef struct _GtkApplicationClass GtkApplicationClass;
41
42struct _GtkApplication
43{
44 GApplication parent_instance;
45};
46
47/**
48 * GtkApplicationClass:
49 * @parent_class: The parent class.
50 * @window_added: Signal emitted when a `GtkWindow` is added to
51 * application through gtk_application_add_window().
52 * @window_removed: Signal emitted when a `GtkWindow` is removed from
53 * application, either as a side-effect of being destroyed or
54 * explicitly through gtk_application_remove_window().
55 */
56struct _GtkApplicationClass
57{
58 GApplicationClass parent_class;
59
60 /*< public >*/
61
62 void (*window_added) (GtkApplication *application,
63 GtkWindow *window);
64 void (*window_removed) (GtkApplication *application,
65 GtkWindow *window);
66
67 /*< private >*/
68 gpointer padding[8];
69};
70
71GDK_AVAILABLE_IN_ALL
72GType gtk_application_get_type (void) G_GNUC_CONST;
73
74GDK_AVAILABLE_IN_ALL
75GtkApplication * gtk_application_new (const char *application_id,
76 GApplicationFlags flags);
77
78GDK_AVAILABLE_IN_ALL
79void gtk_application_add_window (GtkApplication *application,
80 GtkWindow *window);
81
82GDK_AVAILABLE_IN_ALL
83void gtk_application_remove_window (GtkApplication *application,
84 GtkWindow *window);
85GDK_AVAILABLE_IN_ALL
86GList * gtk_application_get_windows (GtkApplication *application);
87
88GDK_AVAILABLE_IN_ALL
89GMenuModel * gtk_application_get_menubar (GtkApplication *application);
90GDK_AVAILABLE_IN_ALL
91void gtk_application_set_menubar (GtkApplication *application,
92 GMenuModel *menubar);
93
94typedef enum
95{
96 GTK_APPLICATION_INHIBIT_LOGOUT = (1 << 0),
97 GTK_APPLICATION_INHIBIT_SWITCH = (1 << 1),
98 GTK_APPLICATION_INHIBIT_SUSPEND = (1 << 2),
99 GTK_APPLICATION_INHIBIT_IDLE = (1 << 3)
100} GtkApplicationInhibitFlags;
101
102GDK_AVAILABLE_IN_ALL
103guint gtk_application_inhibit (GtkApplication *application,
104 GtkWindow *window,
105 GtkApplicationInhibitFlags flags,
106 const char *reason);
107GDK_AVAILABLE_IN_ALL
108void gtk_application_uninhibit (GtkApplication *application,
109 guint cookie);
110
111GDK_AVAILABLE_IN_ALL
112GtkWindow * gtk_application_get_window_by_id (GtkApplication *application,
113 guint id);
114
115GDK_AVAILABLE_IN_ALL
116GtkWindow * gtk_application_get_active_window (GtkApplication *application);
117
118GDK_AVAILABLE_IN_ALL
119char ** gtk_application_list_action_descriptions (GtkApplication *application);
120
121GDK_AVAILABLE_IN_ALL
122char ** gtk_application_get_accels_for_action (GtkApplication *application,
123 const char *detailed_action_name);
124GDK_AVAILABLE_IN_ALL
125char ** gtk_application_get_actions_for_accel (GtkApplication *application,
126 const char *accel);
127
128
129GDK_AVAILABLE_IN_ALL
130void gtk_application_set_accels_for_action (GtkApplication *application,
131 const char *detailed_action_name,
132 const char * const *accels);
133
134GDK_AVAILABLE_IN_ALL
135GMenu * gtk_application_get_menu_by_id (GtkApplication *application,
136 const char *id);
137
138G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkApplication, g_object_unref)
139
140G_END_DECLS
141
142#endif /* __GTK_APPLICATION_H__ */
143

source code of gtk/gtk/gtkapplication.h