]> Pileus Git - ~andy/gtk/blob - gtk/gtkapplication.h
Add gtk_application_end_session
[~andy/gtk] / gtk / gtkapplication.h
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, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  *
19  * Author: Ryan Lortie <desrt@desrt.ca>
20  */
21
22 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
23 #error "Only <gtk/gtk.h> can be included directly."
24 #endif
25
26 #ifndef __GTK_APPLICATION_H__
27 #define __GTK_APPLICATION_H__
28
29 #include <gtk/gtkwidget.h>
30 #include <gio/gio.h>
31
32 G_BEGIN_DECLS
33
34 #define GTK_TYPE_APPLICATION            (gtk_application_get_type ())
35 #define GTK_APPLICATION(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_APPLICATION, GtkApplication))
36 #define GTK_APPLICATION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_APPLICATION, GtkApplicationClass))
37 #define GTK_IS_APPLICATION(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_APPLICATION))
38 #define GTK_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_APPLICATION))
39 #define GTK_APPLICATION_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_APPLICATION, GtkApplicationClass))
40
41 typedef struct _GtkApplication        GtkApplication;
42 typedef struct _GtkApplicationClass   GtkApplicationClass;
43 typedef struct _GtkApplicationPrivate GtkApplicationPrivate;
44
45 struct _GtkApplication
46 {
47   GApplication parent;
48
49   /*< private >*/
50   GtkApplicationPrivate *priv;
51 };
52
53 struct _GtkApplicationClass
54 {
55   GApplicationClass parent_class;
56
57   void (*window_added)   (GtkApplication *application,
58                           GtkWindow      *window);
59   void (*window_removed) (GtkApplication *application,
60                           GtkWindow      *window);
61
62   void (*quit_requested) (GtkApplication *application);
63   void (*quit_cancelled) (GtkApplication *application);
64   void (*quit)           (GtkApplication *application);
65
66   /*< private >*/
67   gpointer padding[11];
68 };
69
70 GType            gtk_application_get_type      (void) G_GNUC_CONST;
71
72 GtkApplication * gtk_application_new           (const gchar       *application_id,
73                                                 GApplicationFlags  flags);
74
75 void             gtk_application_add_window    (GtkApplication    *application,
76                                                 GtkWindow         *window);
77
78 void             gtk_application_remove_window (GtkApplication    *application,
79                                                 GtkWindow         *window);
80 GList *          gtk_application_get_windows   (GtkApplication    *application);
81
82 GMenuModel *     gtk_application_get_app_menu  (GtkApplication    *application);
83 void             gtk_application_set_app_menu  (GtkApplication    *application,
84                                                 GMenuModel        *model);
85
86 GMenuModel *     gtk_application_get_menubar   (GtkApplication    *application);
87 void             gtk_application_set_menubar   (GtkApplication    *application,
88                                                 GMenuModel        *model);
89
90 void             gtk_application_add_accelerator    (GtkApplication  *application,
91                                                      const gchar     *accelerator,
92                                                      const gchar     *action_name,
93                                                      GVariant        *parameter);
94 void             gtk_application_remove_accelerator (GtkApplication *application,
95                                                      const gchar    *action_name,
96                                                      GVariant       *parameter);
97
98 void             gtk_application_quit_response      (GtkApplication *application,
99                                                      gboolean        will_quit,
100                                                      const gchar    *reason);
101
102 typedef enum
103 {
104   GTK_APPLICATION_INHIBIT_LOGOUT  = (1 << 0),
105   GTK_APPLICATION_INHIBIT_SWITCH  = (1 << 1),
106   GTK_APPLICATION_INHIBIT_SUSPEND = (1 << 2),
107   GTK_APPLICATION_INHIBIT_IDLE    = (1 << 3)
108 } GtkApplicationInhibitFlags;
109
110 guint            gtk_application_inhibit            (GtkApplication             *application,
111                                                      GtkWindow                  *window,
112                                                      GtkApplicationInhibitFlags  flags,
113                                                      const gchar                *reason);
114 void             gtk_application_uninhibit          (GtkApplication             *application,
115                                                      guint                       cookie);
116 gboolean         gtk_application_is_inhibited       (GtkApplication             *application,
117                                                      GtkApplicationInhibitFlags  flags);
118
119 typedef enum {
120   GTK_APPLICATION_LOGOUT,
121   GTK_APPLICATION_REBOOT,
122   GTK_APPLICATION_SHUTDOWN
123 } GtkApplicationEndStyle;
124
125 gboolean         gtk_application_end_session        (GtkApplication             *application,
126                                                      GtkApplicationEndStyle      style,
127                                                      gboolean                    request_confirmation);
128
129 G_END_DECLS
130
131 #endif /* __GTK_APPLICATION_H__ */
132