]> git.sur5r.net Git - glabels/blob - glabels2/src/bonobo-mdi.h
Initial revision
[glabels] / glabels2 / src / bonobo-mdi.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * bonobo-mdi.h - definition of a BonoboMDI object
4  *
5  * Copyright (C) 2001-2002 Free Software Foundation
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., 59 Temple Place, Suite 330, 
20  * Boston, MA 02111-1307, USA.
21  *
22  * Author: Paolo Maggi 
23  */
24
25 /*
26  * Modified by the gedit Team, 2001-2002. See the AUTHORS file for a 
27  * list of people on the gedit Team.  
28  * See the ChangeLog files for a list of changes. 
29  */
30
31 #ifndef _BONOBO_MDI_H_
32 #define _BONOBO_MDI_H_
33
34 #include <gtk/gtk.h>
35 #include <bonobo/bonobo-window.h>
36 #include <bonobo/bonobo-ui-component.h>
37
38
39 #include "bonobo-mdi-child.h"
40
41 #define BONOBO_TYPE_MDI            (bonobo_mdi_get_type ())
42 #define BONOBO_MDI(obj)            (GTK_CHECK_CAST ((obj), BONOBO_TYPE_MDI, BonoboMDI))
43 #define BONOBO_MDI_CLASS(klass)    (GTK_CHECK_CLASS_CAST ((klass), BONOBO_TYPE_MDI, BonoboMDIClass))
44 #define BONOBO_IS_MDI(obj)         (GTK_CHECK_TYPE ((obj), BONOBO_TYPE_MDI))
45 #define BONOBO_IS_MDI_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BONOBO_TYPE_MDI))
46 #define BONOBO_MDI_GET_CLASS(obj)  (GTK_CHECK_GET_CLASS ((obj), BONOBO_TYPE_MDI, BonoboMDIClass))
47
48 typedef struct _BonoboMDIPrivate BonoboMDIPrivate;
49
50 typedef struct {
51         GObject                  object;
52
53         BonoboMDIPrivate        *priv;
54 } BonoboMDI;
55
56 typedef struct {
57         GObjectClass    parent_class;
58
59         /* Signals */
60         gboolean        (*add_child)            (BonoboMDI *mdi, BonoboMDIChild *child); 
61         gboolean        (*remove_child)         (BonoboMDI *mdi, BonoboMDIChild *child); 
62         gboolean        (*add_view)             (BonoboMDI *mdi, GtkWidget *view); 
63         gboolean        (*remove_view)          (BonoboMDI *mdi, GtkWidget *view); 
64         void            (*child_changed)        (BonoboMDI *mdi, BonoboMDIChild *child);
65         void            (*view_changed)         (BonoboMDI *mdi, GtkWidget *view);
66         void            (*top_window_created)   (BonoboMDI *mdi, BonoboWindow *window);
67         void            (*top_window_destroy)   (BonoboMDI *mdi, BonoboWindow *window);
68         void            (*all_windows_destroyed)(BonoboMDI *mdi);
69 } BonoboMDIClass;
70
71 typedef struct _BonoboMDIWindowInfo BonoboMDIWindowInfo;
72
73 struct _BonoboMDIWindowInfo {
74         gint width;
75         gint height;
76         
77         GdkWindowState state;
78 };
79
80 /*
81  * description of BonoboMDI signals:
82  *
83  * gboolean add_child(BonoboMDI *, BonoboMDIChild *)
84  * gboolean add_view(BonoboMDI *, GtkWidget *)
85  *   are called before actually adding a mdi_child or a view to the MDI. if the handler returns
86  *   TRUE, the action proceeds otherwise the mdi_child or view are not added.
87  *
88  * gboolean remove_child(BonoboMDI *, BonoboMDIChild *)
89  * gboolean remove_view(BonoboMDI *, GtkWidget *)
90  *   are called before removing mdi_child or view. the handler should return true if the object
91  *   is to be removed from MDI
92  *
93  * void child_changed(BonoboMDI *, BonoboMDIChild *)
94  *   gets called each time when active child is changed with the second argument
95  *   pointing to the old child. mdi->active_view and mdi->active_child still already
96  *   hold the new values
97  *
98  * void view_changed(BonoboMDI *, GtkWidget *)
99  *   is emitted whenever a view is changed, regardless of it being the view of the same child as
100  *   the old view or not. the second argument points to the old view, mdi->active_view and
101  *   mdi->active_child hold the new values. if the child has also been changed, this signal is
102  *   emitted after the child_changed signal.
103  * 
104  * void top_window_created(BonoboMDI *, BonoboWindow *)
105  *   is called with each newly created BonoboWindow to allow the MDI user to customize it (add a
106  *   statusbar, toolbars or menubar if the method with ui templates is not sufficient,
107  *   etc.).
108  *   no contents may be set since BonoboMDI uses them for storing either a view of a child
109  *   or a notebook
110  */
111
112 GType         bonobo_mdi_get_type               (void);
113
114 GObject      *bonobo_mdi_new                    (const gchar *mdi_name, 
115                                                  const gchar *title,
116                                                  gint default_window_width,
117                                                  gint default_window_height);
118
119 void          bonobo_mdi_construct              (BonoboMDI *mdi, 
120                                                  const gchar *name, 
121                                                  const gchar *title,
122                                                  gint default_window_width,
123                                                  gint default_window_height);
124
125 /* setting the ui template*/
126 void          bonobo_mdi_set_ui_template        (BonoboMDI *mdi, 
127                                                  const gchar *xml, 
128                                                  BonoboUIVerb verbs[]);
129 void          bonobo_mdi_set_ui_template_file   (BonoboMDI *mdi, 
130                                                  const gchar *file_name, 
131                                                  BonoboUIVerb verbs[]);
132
133 void          bonobo_mdi_set_child_list_path    (BonoboMDI *mdi, 
134                                                  const gchar *path);
135
136 /* manipulating views */
137 gboolean      bonobo_mdi_add_view               (BonoboMDI *mdi, 
138                                                  BonoboMDIChild *child);
139 gboolean      bonobo_mdi_add_toplevel_view      (BonoboMDI *mdi, 
140                                                  BonoboMDIChild *child,
141                                                  const char *window_role);
142 gboolean      bonobo_mdi_remove_view            (BonoboMDI *mdi, 
143                                                  GtkWidget *view, 
144                                                  gboolean force);
145
146 GtkWidget    *bonobo_mdi_get_active_view        (BonoboMDI *mdi);
147 void          bonobo_mdi_set_active_view        (BonoboMDI *mdi, 
148                                                  GtkWidget *view);
149
150 /* manipulating children */
151 gint          bonobo_mdi_add_child              (BonoboMDI *mdi, 
152                                                  BonoboMDIChild *child);
153 gint          bonobo_mdi_remove_child           (BonoboMDI *mdi, 
154                                                  BonoboMDIChild *child, 
155                                                  gboolean force);
156 gint          bonobo_mdi_remove_all             (BonoboMDI *mdi, 
157                                                  gboolean force);
158
159 void          bonobo_mdi_open_toplevel          (BonoboMDI *mdi,
160                                                  const char *window_role);
161
162 BonoboMDIChild *bonobo_mdi_get_active_child     (BonoboMDI *mdi);
163 BonoboMDIChild *bonobo_mdi_find_child           (BonoboMDI *mdi, 
164                                                  const gchar *name);
165
166 BonoboWindow   *bonobo_mdi_get_active_window    (BonoboMDI *mdi);
167
168 /*
169  * the following two functions are here to make life easier if an application
170  * creates objects (like opening a window) that should "keep the application
171  * alive" even if there are no MDI windows open. any such windows should be
172  * registered with the MDI: as long as there is a window registered, the MDI
173  * will not destroy itself (even if the last of its windows is closed). on the
174  * other hand, closing the last MDI window when no objects are registered
175  * with the MDI will result in MDI being gtk_object_destroy()ed.
176  */
177 void          bonobo_mdi_register               (BonoboMDI *mdi, 
178                                                  GObject *object);
179 void          bonobo_mdi_unregister             (BonoboMDI *mdi, 
180                                                  GObject *object);
181
182 /*
183  * convenience functions for retrieveing BonoboMDIChild and BonoboApp
184  * objects associated with a particular view and for retrieveing the
185  * visible view of a certain BonoboWindow.
186  */
187 BonoboWindow            *bonobo_mdi_get_window_from_view        (GtkWidget *view);
188 BonoboMDIChild          *bonobo_mdi_get_child_from_view         (GtkWidget *view);
189 GtkWidget               *bonobo_mdi_get_view_from_window        (BonoboMDI *mdi, 
190                                                                  BonoboWindow *window);
191
192 GList                   *bonobo_mdi_get_children                (BonoboMDI *mdi);
193 GList                   *bonobo_mdi_get_windows                 (BonoboMDI *mdi);
194
195 BonoboUIComponent       *bonobo_mdi_get_ui_component_from_window (BonoboWindow *win);
196
197 /* Utility function to generate unique window roles */
198 char *bonobo_mdi_generate_window_role (void);
199
200 const BonoboMDIWindowInfo *bonobo_mdi_get_window_info           (BonoboWindow *win);
201
202 #endif /* _BONOBO_MDI_H_ */
203
204