1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * bonobo-mdi.h - definition of a BonoboMDI object
5 * Copyright (C) 2001-2002 Free Software Foundation
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.
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.
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.
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.
31 #ifndef _BONOBO_MDI_H_
32 #define _BONOBO_MDI_H_
35 #include <bonobo/bonobo-window.h>
36 #include <bonobo/bonobo-ui-component.h>
39 #include "bonobo-mdi-child.h"
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))
48 typedef struct _BonoboMDIPrivate BonoboMDIPrivate;
53 BonoboMDIPrivate *priv;
57 GObjectClass parent_class;
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);
71 typedef struct _BonoboMDIWindowInfo BonoboMDIWindowInfo;
73 struct _BonoboMDIWindowInfo {
81 * description of BonoboMDI signals:
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.
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
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
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.
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,
108 * no contents may be set since BonoboMDI uses them for storing either a view of a child
112 GType bonobo_mdi_get_type (void);
114 GObject *bonobo_mdi_new (const gchar *mdi_name,
116 gint default_window_width,
117 gint default_window_height);
119 void bonobo_mdi_construct (BonoboMDI *mdi,
122 gint default_window_width,
123 gint default_window_height);
125 /* setting the ui template*/
126 void bonobo_mdi_set_ui_template (BonoboMDI *mdi,
128 BonoboUIVerb verbs[]);
129 void bonobo_mdi_set_ui_template_file (BonoboMDI *mdi,
130 const gchar *file_name,
131 BonoboUIVerb verbs[]);
133 void bonobo_mdi_set_child_list_path (BonoboMDI *mdi,
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,
146 GtkWidget *bonobo_mdi_get_active_view (BonoboMDI *mdi);
147 void bonobo_mdi_set_active_view (BonoboMDI *mdi,
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,
156 gint bonobo_mdi_remove_all (BonoboMDI *mdi,
159 void bonobo_mdi_open_toplevel (BonoboMDI *mdi,
160 const char *window_role);
162 BonoboMDIChild *bonobo_mdi_get_active_child (BonoboMDI *mdi);
163 BonoboMDIChild *bonobo_mdi_find_child (BonoboMDI *mdi,
166 BonoboWindow *bonobo_mdi_get_active_window (BonoboMDI *mdi);
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.
177 void bonobo_mdi_register (BonoboMDI *mdi,
179 void bonobo_mdi_unregister (BonoboMDI *mdi,
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.
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);
192 GList *bonobo_mdi_get_children (BonoboMDI *mdi);
193 GList *bonobo_mdi_get_windows (BonoboMDI *mdi);
195 BonoboUIComponent *bonobo_mdi_get_ui_component_from_window (BonoboWindow *win);
197 /* Utility function to generate unique window roles */
198 char *bonobo_mdi_generate_window_role (void);
200 const BonoboMDIWindowInfo *bonobo_mdi_get_window_info (BonoboWindow *win);
202 #endif /* _BONOBO_MDI_H_ */