2 * (GLABELS) Label and Business Card Creation program for GNOME
4 * mdi.c: gLabels MDI module
6 * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * This file is based on gedit-mdi.c from gedit2:
26 * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
27 * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
28 * Copyright (C) 2002 Paolo Maggi
33 #include <libgnome/libgnome.h>
34 #include <libgnomeui/libgnomeui.h>
35 #include <libgnomevfs/gnome-vfs.h>
40 #include "mdi-child.h"
48 #include "gnome-recent-view.h"
50 #include <bonobo/bonobo-ui-util.h>
51 #include <bonobo/bonobo-control.h>
53 #include <gconf/gconf-client.h>
55 /*========================================================*/
56 /* Private macros and constants. */
57 /*========================================================*/
59 #define DEFAULT_WINDOW_WIDTH 500
60 #define DEFAULT_WINDOW_HEIGHT 375
62 /*========================================================*/
64 /*========================================================*/
72 /*========================================================*/
73 /* Private globals. */
74 /*========================================================*/
76 static BonoboMDIClass *parent_class = NULL;
79 /*========================================================*/
80 /* Private function prototypes. */
81 /*========================================================*/
83 static void gl_mdi_class_init (glMDIClass *klass);
84 static void gl_mdi_init (glMDI *mdi);
85 static void gl_mdi_finalize (GObject *object);
87 static void gl_mdi_app_created_cb (BonoboMDI *mdi, BonoboWindow *win);
88 static void gl_mdi_set_app_toolbar_style (BonoboWindow *win);
89 static void gl_mdi_set_app_statusbar_style (BonoboWindow *win);
91 static gint gl_mdi_add_child_cb (BonoboMDI *mdi, BonoboMDIChild *child);
92 static gint gl_mdi_add_view_cb (BonoboMDI *mdi, GtkWidget *view);
93 static gint gl_mdi_remove_child_cb (BonoboMDI *mdi, BonoboMDIChild *child);
94 static gint gl_mdi_remove_view_cb (BonoboMDI *mdi, GtkWidget *view);
96 static void gl_mdi_view_changed_cb (BonoboMDI *mdi, GtkWidget *old_view);
97 static void gl_mdi_child_changed_cb (BonoboMDI *mdi, BonoboMDIChild *old_child);
98 static void gl_mdi_child_state_changed_cb (glMDIChild *child);
100 static void gl_mdi_set_active_window_undo_redo_verbs_sensitivity (BonoboMDI *mdi);
102 static void gl_mdi_view_menu_item_toggled_cb (
103 BonoboUIComponent *ui_component,
105 Bonobo_UIComponent_EventType type,
110 /*****************************************************************************/
111 /* Boilerplate object stuff. */
112 /*****************************************************************************/
114 gl_mdi_get_type (void)
116 static GType mdi_type = 0;
120 static const GTypeInfo our_info =
123 NULL, /* base_init */
124 NULL, /* base_finalize */
125 (GClassInitFunc) gl_mdi_class_init,
126 NULL, /* class_finalize */
127 NULL, /* class_data */
130 (GInstanceInitFunc) gl_mdi_init
133 mdi_type = g_type_register_static (BONOBO_TYPE_MDI,
143 gl_mdi_class_init (glMDIClass *klass)
145 GObjectClass *object_class = G_OBJECT_CLASS (klass);
147 gl_debug (DEBUG_MDI, "START");
149 parent_class = g_type_class_peek_parent (klass);
151 object_class->finalize = gl_mdi_finalize;
153 gl_debug (DEBUG_MDI, "END");
157 gl_mdi_init (glMDI *mdi)
159 gl_debug (DEBUG_MDI, "START");
161 bonobo_mdi_construct (BONOBO_MDI (mdi), "glabels", "gLabels",
162 DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT);
164 mdi->priv = g_new0 (glMDIPrivate, 1);
166 mdi->priv->untitled_number = 0;
168 bonobo_mdi_set_ui_template_file (BONOBO_MDI (mdi),
169 GLABELS_UI_DIR "glabels-ui.xml",
172 bonobo_mdi_set_child_list_path (BONOBO_MDI (mdi), "/menu/Documents/");
174 /* Connect signals */
175 g_signal_connect (G_OBJECT (mdi), "top_window_created",
176 G_CALLBACK (gl_mdi_app_created_cb), NULL);
178 g_signal_connect (G_OBJECT (mdi), "add_child",
179 G_CALLBACK (gl_mdi_add_child_cb), NULL);
180 g_signal_connect (G_OBJECT (mdi), "add_view",
181 G_CALLBACK (gl_mdi_add_view_cb), NULL);
183 g_signal_connect (G_OBJECT (mdi), "remove_child",
184 G_CALLBACK (gl_mdi_remove_child_cb), NULL);
185 g_signal_connect (G_OBJECT (mdi), "remove_view",
186 G_CALLBACK (gl_mdi_remove_view_cb), NULL);
188 g_signal_connect (G_OBJECT (mdi), "child_changed",
189 G_CALLBACK (gl_mdi_child_changed_cb), NULL);
190 g_signal_connect (G_OBJECT (mdi), "view_changed",
191 G_CALLBACK (gl_mdi_view_changed_cb), NULL);
193 g_signal_connect (G_OBJECT (mdi), "all_windows_destroyed",
194 G_CALLBACK (gl_file_exit), NULL);
196 gl_debug (DEBUG_MDI, "END");
200 gl_mdi_finalize (GObject *object)
204 gl_debug (DEBUG_MDI, "START");
206 g_return_if_fail (object != NULL);
208 mdi = GL_MDI (object);
210 g_return_if_fail (GL_IS_MDI (mdi));
211 g_return_if_fail (mdi->priv != NULL);
213 G_OBJECT_CLASS (parent_class)->finalize (object);
217 gl_debug (DEBUG_MDI, "END");
221 /*****************************************************************************/
222 /* NEW mdi objecg. */
223 /*****************************************************************************/
229 gl_debug (DEBUG_MDI, "START");
231 mdi = GL_MDI (g_object_new (GL_TYPE_MDI, NULL));
232 g_return_val_if_fail (mdi != NULL, NULL);
234 gl_debug (DEBUG_MDI, "END");
238 /*---------------------------------------------------------------------------*/
239 /* App created callback. */
240 /*---------------------------------------------------------------------------*/
242 gl_mdi_app_created_cb (BonoboMDI *mdi, BonoboWindow *win)
245 BonoboControl *control;
246 BonoboUIComponent *ui_component;
247 GnomeRecentView *view;
248 GnomeRecentModel *model;
250 static GtkTargetEntry drag_types[] =
252 { "text/uri-list", 0, 0 },
255 static gint n_drag_types =
256 sizeof (drag_types) / sizeof (drag_types [0]);
258 gl_debug (DEBUG_MDI, "START");
260 ui_component = bonobo_mdi_get_ui_component_from_window (win);
261 g_return_if_fail (ui_component != NULL);
263 /* Set the toolbar style according to prefs */
264 gl_mdi_set_app_toolbar_style (win);
266 /* Add listener fo the view menu */
267 bonobo_ui_component_add_listener (ui_component, "ViewToolbar",
268 (BonoboUIListenerFn)gl_mdi_view_menu_item_toggled_cb,
271 bonobo_ui_component_add_listener (ui_component, "ToolbarSystem",
272 (BonoboUIListenerFn)gl_mdi_view_menu_item_toggled_cb,
274 bonobo_ui_component_add_listener (ui_component, "ToolbarIcon",
275 (BonoboUIListenerFn)gl_mdi_view_menu_item_toggled_cb,
277 bonobo_ui_component_add_listener (ui_component, "ToolbarIconText",
278 (BonoboUIListenerFn)gl_mdi_view_menu_item_toggled_cb,
280 bonobo_ui_component_add_listener (ui_component, "ToolbarTooltips",
281 (BonoboUIListenerFn)gl_mdi_view_menu_item_toggled_cb,
285 gl_menus_set_verb_list_sensitive (ui_component,
286 gl_menus_no_docs_sensible_verbs,
289 /* add a GeditRecentView object */
290 model = gl_recent_get_model ();
291 view = GNOME_RECENT_VIEW (gnome_recent_view_bonobo_new (ui_component,
292 "/menu/File/Recents"));
293 gnome_recent_view_set_model (view, model);
295 g_signal_connect (G_OBJECT (view), "activate",
296 G_CALLBACK (gl_file_open_recent), win);
298 gl_debug (DEBUG_MDI, "END");
301 /*---------------------------------------------------------------------------*/
302 /* Menu item togglded callback. */
303 /*---------------------------------------------------------------------------*/
305 gl_mdi_view_menu_item_toggled_cb (
306 BonoboUIComponent *ui_component,
308 Bonobo_UIComponent_EventType type,
314 gl_debug (DEBUG_MDI, "%s toggled to '%s'", path, state);
316 s = (strcmp (state, "1") == 0);
318 if ((strcmp (path, "ViewToolbar") == 0) &&
319 (s != gl_prefs->toolbar_visible))
321 gl_prefs->toolbar_visible = s;
322 gl_mdi_set_app_toolbar_style (win);
327 if (s && (strcmp (path, "ToolbarSystem") == 0) &&
328 (gl_prefs->toolbar_buttons_style != GL_TOOLBAR_SYSTEM))
330 gl_prefs->toolbar_buttons_style = GL_TOOLBAR_SYSTEM;
331 gl_mdi_set_app_toolbar_style (win);
336 if (s && (strcmp (path, "ToolbarIcon") == 0) &&
337 (gl_prefs->toolbar_buttons_style != GL_TOOLBAR_ICONS))
339 gl_prefs->toolbar_buttons_style = GL_TOOLBAR_ICONS;
340 gl_mdi_set_app_toolbar_style (win);
345 if (s && (strcmp (path, "ToolbarIconText") == 0) &&
346 (gl_prefs->toolbar_buttons_style != GL_TOOLBAR_ICONS_AND_TEXT))
348 gl_prefs->toolbar_buttons_style = GL_TOOLBAR_ICONS_AND_TEXT;
349 gl_mdi_set_app_toolbar_style (win);
354 if ((strcmp (path, "ToolbarTooltips") == 0) &&
355 (s != gl_prefs->toolbar_view_tooltips))
357 gl_prefs->toolbar_view_tooltips = s;
358 gl_mdi_set_app_toolbar_style (win);
365 /*---------------------------------------------------------------------------*/
366 /* Set toolbar style. */
367 /*---------------------------------------------------------------------------*/
369 gl_mdi_set_app_toolbar_style (BonoboWindow *win)
371 BonoboUIComponent *ui_component;
375 gl_debug (DEBUG_MDI, "START");
377 g_return_if_fail (BONOBO_IS_WINDOW (win));
379 ui_component = bonobo_mdi_get_ui_component_from_window (win);
380 g_return_if_fail (ui_component != NULL);
382 bonobo_ui_component_freeze (ui_component, NULL);
384 /* Updated view menu */
385 gl_menus_set_verb_state (ui_component,
386 "/commands/ViewToolbar",
387 gl_prefs->toolbar_visible);
389 gl_menus_set_verb_sensitive (ui_component,
390 "/commands/ToolbarSystem",
391 gl_prefs->toolbar_visible);
392 gl_menus_set_verb_sensitive (ui_component,
393 "/commands/ToolbarIcon",
394 gl_prefs->toolbar_visible);
395 gl_menus_set_verb_sensitive (ui_component,
396 "/commands/ToolbarIconText",
397 gl_prefs->toolbar_visible);
398 gl_menus_set_verb_sensitive (ui_component,
399 "/commands/ToolbarTooltips",
400 gl_prefs->toolbar_visible);
402 gl_menus_set_verb_state (ui_component,
403 "/commands/ToolbarSystem",
404 gl_prefs->toolbar_buttons_style == GL_TOOLBAR_SYSTEM);
406 gl_menus_set_verb_state (ui_component,
407 "/commands/ToolbarIcon",
408 gl_prefs->toolbar_buttons_style == GL_TOOLBAR_ICONS);
410 gl_menus_set_verb_state (ui_component,
411 "/commands/ToolbarIconText",
412 gl_prefs->toolbar_buttons_style == GL_TOOLBAR_ICONS_AND_TEXT);
414 gl_menus_set_verb_state (ui_component,
415 "/commands/ToolbarTooltips",
416 gl_prefs->toolbar_view_tooltips);
419 /* Actually update toolbar style */
420 bonobo_ui_component_set_prop (
421 ui_component, "/Toolbar",
422 "tips", gl_prefs->toolbar_view_tooltips ? "1" : "0",
425 switch (gl_prefs->toolbar_buttons_style)
427 case GL_TOOLBAR_SYSTEM:
429 client = gconf_client_get_default ();
433 labels = gconf_client_get_bool (client,
434 "/desktop/gnome/interface/toolbar-labels", NULL);
436 g_object_unref (G_OBJECT (client));
440 gl_debug (DEBUG_MDI, "SYSTEM: BOTH");
441 bonobo_ui_component_set_prop (
442 ui_component, "/Toolbar", "look", "both", NULL);
447 gl_debug (DEBUG_MDI, "SYSTEM: ICONS");
448 bonobo_ui_component_set_prop (
449 ui_component, "/Toolbar", "look", "icons", NULL);
454 case GL_TOOLBAR_ICONS:
455 gl_debug (DEBUG_MDI, "GLABELS: ICONS");
456 bonobo_ui_component_set_prop (
457 ui_component, "/Toolbar", "look", "icon", NULL);
461 case GL_TOOLBAR_ICONS_AND_TEXT:
462 gl_debug (DEBUG_MDI, "GLABELS: ICONS_AND_TEXT");
463 bonobo_ui_component_set_prop (
464 ui_component, "/Toolbar", "look", "both", NULL);
472 bonobo_ui_component_set_prop (
473 ui_component, "/Toolbar",
474 "hidden", gl_prefs->toolbar_visible ? "0":"1", NULL);
477 bonobo_ui_component_thaw (ui_component, NULL);
479 gl_debug (DEBUG_MDI, "END");
483 /*---------------------------------------------------------------------------*/
484 /* Child state changed callback. */
485 /*---------------------------------------------------------------------------*/
487 gl_mdi_child_state_changed_cb (glMDIChild *child)
489 gl_debug (DEBUG_MDI, "START");
491 if (bonobo_mdi_get_active_child (BONOBO_MDI (glabels_mdi)) != BONOBO_MDI_CHILD (child))
494 gl_mdi_set_active_window_title (BONOBO_MDI (glabels_mdi));
495 gl_mdi_set_active_window_verbs_sensitivity (BONOBO_MDI (glabels_mdi));
497 gl_debug (DEBUG_MDI, "END");
500 /*---------------------------------------------------------------------------*/
501 /* Child undo/redo state changed callback. */
502 /*---------------------------------------------------------------------------*/
504 gl_mdi_child_undo_redo_state_changed_cb (glMDIChild *child)
506 gl_debug (DEBUG_MDI, "START");
508 if (bonobo_mdi_get_active_child (BONOBO_MDI (glabels_mdi)) != BONOBO_MDI_CHILD (child))
511 gl_mdi_set_active_window_undo_redo_verbs_sensitivity (BONOBO_MDI (glabels_mdi));
512 gl_debug (DEBUG_MDI, "END");
515 /*---------------------------------------------------------------------------*/
516 /* Add child callback. */
517 /*---------------------------------------------------------------------------*/
519 gl_mdi_add_child_cb (BonoboMDI *mdi, BonoboMDIChild *child)
521 gl_debug (DEBUG_MDI, "START");
523 g_signal_connect (G_OBJECT (child), "state_changed",
524 G_CALLBACK (gl_mdi_child_state_changed_cb),
526 g_signal_connect (G_OBJECT (child), "undo_redo_state_changed",
527 G_CALLBACK (gl_mdi_child_undo_redo_state_changed_cb),
530 gl_debug (DEBUG_MDI, "END");
534 /*---------------------------------------------------------------------------*/
535 /* Add view callback. */
536 /*---------------------------------------------------------------------------*/
538 gl_mdi_add_view_cb (BonoboMDI *mdi, GtkWidget *view)
540 gl_debug (DEBUG_MDI, "START");
541 gl_debug (DEBUG_MDI, "END");
545 /*---------------------------------------------------------------------------*/
546 /* Remove child callback. */
547 /*---------------------------------------------------------------------------*/
549 gl_mdi_remove_child_cb (BonoboMDI *mdi, BonoboMDIChild *child)
552 gboolean close = TRUE;
554 gl_debug (DEBUG_MDI, "START");
556 g_return_val_if_fail (child != NULL, FALSE);
557 g_return_val_if_fail (GL_MDI_CHILD (child)->label != NULL, FALSE);
559 doc = GL_MDI_CHILD (child)->label;
561 if (gl_label_is_modified (doc))
563 GtkWidget *msgbox, *w;
564 gchar *fname = NULL, *msg = NULL;
568 w = GTK_WIDGET (g_list_nth_data (bonobo_mdi_child_get_views (child), 0));
571 bonobo_mdi_set_active_view (mdi, w);
573 fname = gl_label_get_short_name (doc);
575 msgbox = gtk_message_dialog_new (GTK_WINDOW (bonobo_mdi_get_active_window (mdi)),
576 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
577 GTK_MESSAGE_QUESTION,
579 _("Do you want to save the changes you made to the document \"%s\"? \n\n"
580 "Your changes will be lost if you don't save them."),
583 gl_util_dialog_add_button (GTK_DIALOG (msgbox),
588 if (glabels_close_x_button_pressed)
590 else if (glabels_exit_button_pressed)
594 /* Delete event generated */
595 if (g_list_length (bonobo_mdi_get_windows (BONOBO_MDI (glabels_mdi))) == 1)
603 gl_util_dialog_add_button (GTK_DIALOG (msgbox),
606 GTK_RESPONSE_CANCEL);
608 gl_util_dialog_add_button (GTK_DIALOG (msgbox),
611 GTK_RESPONSE_CANCEL);
614 gtk_dialog_add_button (GTK_DIALOG (msgbox), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
616 gtk_dialog_add_button (GTK_DIALOG (msgbox),
620 gtk_dialog_set_default_response (GTK_DIALOG (msgbox), GTK_RESPONSE_YES);
622 gtk_window_set_resizable (GTK_WINDOW (msgbox), FALSE);
624 ret = gtk_dialog_run (GTK_DIALOG (msgbox));
626 gtk_widget_destroy (msgbox);
633 case GTK_RESPONSE_YES:
634 close = gl_file_save (GL_MDI_CHILD (child));
636 case GTK_RESPONSE_NO:
643 gl_debug (DEBUG_MDI, "CLOSE: %s", close ? "TRUE" : "FALSE");
646 /* FIXME: there is a bug if you "close all" >1 docs, don't save the document
647 * and then don't close the last one.
649 /* Disable to avoid the bug */
653 g_signal_handlers_disconnect_by_func (child,
654 G_CALLBACK (gl_mdi_child_state_changed_cb),
656 g_signal_handlers_disconnect_by_func (GTK_OBJECT (child),
657 G_CALLBACK (gl_mdi_child_undo_redo_state_changed_cb),
662 gl_debug (DEBUG_MDI, "END");
666 /*---------------------------------------------------------------------------*/
667 /* Remove view callback. */
668 /*---------------------------------------------------------------------------*/
670 gl_mdi_remove_view_cb (BonoboMDI *mdi, GtkWidget *view)
672 gl_debug (DEBUG_MDI, "");
673 gl_debug (DEBUG_MDI, "END");
678 /*****************************************************************************/
679 /* Set title of active window. */
680 /*****************************************************************************/
682 gl_mdi_set_active_window_title (BonoboMDI *mdi)
684 BonoboMDIChild* active_child = NULL;
686 gchar* docname = NULL;
689 gl_debug (DEBUG_MDI, "START");
692 active_child = bonobo_mdi_get_active_child (mdi);
693 if (active_child == NULL)
696 doc = GL_MDI_CHILD (active_child)->label;
697 g_return_if_fail (doc != NULL);
699 /* Set active window title */
700 docname = gl_label_get_short_name (doc);
701 g_return_if_fail (docname != NULL);
703 if (gl_label_is_modified (doc))
705 title = g_strdup_printf ("%s %s - glabels",
706 docname, _("(modified)"));
710 title = g_strdup_printf ("%s - glabels", docname);
714 gtk_window_set_title (GTK_WINDOW (bonobo_mdi_get_active_window (mdi)), title);
719 gl_debug (DEBUG_MDI, "END");
722 /*---------------------------------------------------------------------------*/
723 /* Child changed callback. */
724 /*---------------------------------------------------------------------------*/
726 void gl_mdi_child_changed_cb (BonoboMDI *mdi, BonoboMDIChild *old_child)
728 gl_debug (DEBUG_MDI, "START");
730 gl_mdi_set_active_window_title (mdi);
732 gl_debug (DEBUG_MDI, "END");
735 /*---------------------------------------------------------------------------*/
736 /* View changed callback. */
737 /*---------------------------------------------------------------------------*/
739 void gl_mdi_view_changed_cb (BonoboMDI *mdi, GtkWidget *old_view)
743 GtkWidget *active_view;
745 gl_debug (DEBUG_MDI, "START");
747 gl_mdi_set_active_window_verbs_sensitivity (mdi);
749 active_view = bonobo_mdi_get_active_view (mdi);
751 win = bonobo_mdi_get_active_window (mdi);
752 g_return_if_fail (win != NULL);
754 gl_debug (DEBUG_MDI, "END");
757 /*****************************************************************************/
758 /* Set sensitivity of verbs in active window. */
759 /*****************************************************************************/
761 gl_mdi_set_active_window_verbs_sensitivity (BonoboMDI *mdi)
763 /* FIXME: it is too slooooooow! - Paolo */
765 BonoboWindow* active_window = NULL;
766 BonoboMDIChild* active_child = NULL;
768 BonoboUIComponent *ui_component;
770 gl_debug (DEBUG_MDI, "START");
772 active_window = bonobo_mdi_get_active_window (mdi);
774 if (active_window == NULL)
777 ui_component = bonobo_mdi_get_ui_component_from_window (active_window);
778 g_return_if_fail (ui_component != NULL);
780 active_child = bonobo_mdi_get_active_child (mdi);
782 bonobo_ui_component_freeze (ui_component, NULL);
784 if (active_child == NULL)
786 gl_menus_set_verb_list_sensitive (ui_component,
787 gl_menus_no_docs_sensible_verbs, FALSE);
792 gl_menus_set_verb_list_sensitive (ui_component,
793 gl_menus_all_sensible_verbs, TRUE);
796 doc = GL_MDI_CHILD (active_child)->label;
797 g_return_if_fail (doc != NULL);
799 if (!gl_label_can_undo (doc))
800 gl_menus_set_verb_sensitive (ui_component,
801 "/commands/EditUndo", FALSE);
803 if (!gl_label_can_redo (doc))
804 gl_menus_set_verb_sensitive (ui_component,
805 "/commands/EditRedo", FALSE);
807 if (!gl_label_is_modified (doc))
809 gl_menus_set_verb_list_sensitive (ui_component,
810 gl_menus_not_modified_doc_sensible_verbs,
816 bonobo_ui_component_thaw (ui_component, NULL);
818 gl_debug (DEBUG_MDI, "END");
822 /*****************************************************************************/
823 /* Set sensitivity of undo/redo verbs in active window. */
824 /*****************************************************************************/
826 gl_mdi_set_active_window_undo_redo_verbs_sensitivity (BonoboMDI *mdi)
828 BonoboWindow* active_window = NULL;
829 BonoboMDIChild* active_child = NULL;
831 BonoboUIComponent *ui_component;
833 gl_debug (DEBUG_MDI, "START");
835 active_window = bonobo_mdi_get_active_window (mdi);
836 g_return_if_fail (active_window != NULL);
838 ui_component = bonobo_mdi_get_ui_component_from_window (active_window);
839 g_return_if_fail (ui_component != NULL);
841 active_child = bonobo_mdi_get_active_child (mdi);
842 doc = GL_MDI_CHILD (active_child)->label;
843 g_return_if_fail (doc != NULL);
845 bonobo_ui_component_freeze (ui_component, NULL);
847 gl_menus_set_verb_sensitive (ui_component, "/commands/EditUndo",
848 gl_label_can_undo (doc));
850 gl_menus_set_verb_sensitive (ui_component, "/commands/EditRedo",
851 gl_label_can_redo (doc));
853 bonobo_ui_component_thaw (ui_component, NULL);
855 gl_debug (DEBUG_MDI, "END");