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"
51 #include <bonobo/bonobo-ui-util.h>
52 #include <bonobo/bonobo-control.h>
54 #include <gconf/gconf-client.h>
56 /*========================================================*/
57 /* Private macros and constants. */
58 /*========================================================*/
60 #define DEFAULT_WINDOW_WIDTH 500
61 #define DEFAULT_WINDOW_HEIGHT 375
63 /*========================================================*/
65 /*========================================================*/
73 /*========================================================*/
74 /* Private globals. */
75 /*========================================================*/
77 static BonoboMDIClass *parent_class = NULL;
80 /*========================================================*/
81 /* Private function prototypes. */
82 /*========================================================*/
84 static void gl_mdi_class_init (glMDIClass *klass);
85 static void gl_mdi_init (glMDI *mdi);
86 static void gl_mdi_finalize (GObject *object);
88 static void gl_mdi_app_created_cb (BonoboMDI *mdi, BonoboWindow *win);
89 static void gl_mdi_set_app_toolbar_style (BonoboWindow *win);
90 static void gl_mdi_set_app_statusbar_style (BonoboWindow *win);
92 static gint gl_mdi_add_child_cb (BonoboMDI *mdi, BonoboMDIChild *child);
93 static gint gl_mdi_add_view_cb (BonoboMDI *mdi, GtkWidget *view);
94 static gint gl_mdi_remove_child_cb (BonoboMDI *mdi, BonoboMDIChild *child);
95 static gint gl_mdi_remove_view_cb (BonoboMDI *mdi, GtkWidget *view);
97 static void gl_mdi_view_changed_cb (BonoboMDI *mdi, GtkWidget *old_view);
98 static void gl_mdi_child_changed_cb (BonoboMDI *mdi, BonoboMDIChild *old_child);
99 static void gl_mdi_child_state_changed_cb (glMDIChild *child);
101 static void gl_mdi_set_active_window_undo_redo_verbs_sensitivity (BonoboMDI *mdi);
102 static void gl_mdi_set_active_window_selection_verbs_sensitivity (BonoboMDI *mdi);
104 static void gl_mdi_view_menu_item_toggled_cb (
105 BonoboUIComponent *ui_component,
107 Bonobo_UIComponent_EventType type,
112 /*****************************************************************************/
113 /* Boilerplate object stuff. */
114 /*****************************************************************************/
116 gl_mdi_get_type (void)
118 static GType mdi_type = 0;
122 static const GTypeInfo our_info =
125 NULL, /* base_init */
126 NULL, /* base_finalize */
127 (GClassInitFunc) gl_mdi_class_init,
128 NULL, /* class_finalize */
129 NULL, /* class_data */
132 (GInstanceInitFunc) gl_mdi_init
135 mdi_type = g_type_register_static (BONOBO_TYPE_MDI,
145 gl_mdi_class_init (glMDIClass *klass)
147 GObjectClass *object_class = G_OBJECT_CLASS (klass);
149 gl_debug (DEBUG_MDI, "START");
151 parent_class = g_type_class_peek_parent (klass);
153 object_class->finalize = gl_mdi_finalize;
155 gl_debug (DEBUG_MDI, "END");
159 gl_mdi_init (glMDI *mdi)
161 gl_debug (DEBUG_MDI, "START");
163 bonobo_mdi_construct (BONOBO_MDI (mdi), "glabels", "gLabels",
164 DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT);
166 mdi->priv = g_new0 (glMDIPrivate, 1);
168 mdi->priv->untitled_number = 0;
170 bonobo_mdi_set_ui_template_file (BONOBO_MDI (mdi),
171 GLABELS_UI_DIR "glabels-ui.xml",
174 bonobo_mdi_set_child_list_path (BONOBO_MDI (mdi), "/menu/Documents/");
176 /* Connect signals */
177 g_signal_connect (G_OBJECT (mdi), "top_window_created",
178 G_CALLBACK (gl_mdi_app_created_cb), NULL);
180 g_signal_connect (G_OBJECT (mdi), "add_child",
181 G_CALLBACK (gl_mdi_add_child_cb), NULL);
182 g_signal_connect (G_OBJECT (mdi), "add_view",
183 G_CALLBACK (gl_mdi_add_view_cb), NULL);
185 g_signal_connect (G_OBJECT (mdi), "remove_child",
186 G_CALLBACK (gl_mdi_remove_child_cb), NULL);
187 g_signal_connect (G_OBJECT (mdi), "remove_view",
188 G_CALLBACK (gl_mdi_remove_view_cb), NULL);
190 g_signal_connect (G_OBJECT (mdi), "child_changed",
191 G_CALLBACK (gl_mdi_child_changed_cb), NULL);
192 g_signal_connect (G_OBJECT (mdi), "view_changed",
193 G_CALLBACK (gl_mdi_view_changed_cb), NULL);
195 g_signal_connect (G_OBJECT (mdi), "all_windows_destroyed",
196 G_CALLBACK (gl_file_exit), NULL);
198 gl_debug (DEBUG_MDI, "END");
202 gl_mdi_finalize (GObject *object)
206 gl_debug (DEBUG_MDI, "START");
208 g_return_if_fail (object != NULL);
210 mdi = GL_MDI (object);
212 g_return_if_fail (GL_IS_MDI (mdi));
213 g_return_if_fail (mdi->priv != NULL);
215 G_OBJECT_CLASS (parent_class)->finalize (object);
219 gl_debug (DEBUG_MDI, "END");
223 /*****************************************************************************/
224 /* NEW mdi object. */
225 /*****************************************************************************/
231 gl_debug (DEBUG_MDI, "START");
233 mdi = GL_MDI (g_object_new (GL_TYPE_MDI, NULL));
234 g_return_val_if_fail (mdi != NULL, NULL);
236 gl_debug (DEBUG_MDI, "END");
240 /*---------------------------------------------------------------------------*/
241 /* App created callback. */
242 /*---------------------------------------------------------------------------*/
244 gl_mdi_app_created_cb (BonoboMDI *mdi, BonoboWindow *win)
247 BonoboControl *control;
248 BonoboUIComponent *ui_component;
249 GnomeRecentView *view;
250 GnomeRecentModel *model;
252 static GtkTargetEntry drag_types[] =
254 { "text/uri-list", 0, 0 },
257 static gint n_drag_types =
258 sizeof (drag_types) / sizeof (drag_types [0]);
260 gl_debug (DEBUG_MDI, "START");
262 ui_component = bonobo_mdi_get_ui_component_from_window (win);
263 g_return_if_fail (ui_component != NULL);
265 /* Set the toolbar style according to prefs */
266 gl_mdi_set_app_toolbar_style (win);
268 /* Add listener fo the view menu */
269 bonobo_ui_component_add_listener (ui_component, "ViewToolbar",
270 (BonoboUIListenerFn)gl_mdi_view_menu_item_toggled_cb,
273 bonobo_ui_component_add_listener (ui_component, "ToolbarSystem",
274 (BonoboUIListenerFn)gl_mdi_view_menu_item_toggled_cb,
276 bonobo_ui_component_add_listener (ui_component, "ToolbarIcon",
277 (BonoboUIListenerFn)gl_mdi_view_menu_item_toggled_cb,
279 bonobo_ui_component_add_listener (ui_component, "ToolbarIconText",
280 (BonoboUIListenerFn)gl_mdi_view_menu_item_toggled_cb,
282 bonobo_ui_component_add_listener (ui_component, "ToolbarTooltips",
283 (BonoboUIListenerFn)gl_mdi_view_menu_item_toggled_cb,
287 gl_ui_set_verb_list_sensitive (ui_component,
288 gl_ui_no_docs_sensible_verbs,
291 /* add a GeditRecentView object */
292 model = gl_recent_get_model ();
293 view = GNOME_RECENT_VIEW (gnome_recent_view_bonobo_new (ui_component,
294 "/menu/File/Recents"));
295 gnome_recent_view_set_model (view, model);
297 g_signal_connect (G_OBJECT (view), "activate",
298 G_CALLBACK (gl_file_open_recent), win);
300 gl_debug (DEBUG_MDI, "END");
303 /*---------------------------------------------------------------------------*/
304 /* Menu item togglded callback. */
305 /*---------------------------------------------------------------------------*/
307 gl_mdi_view_menu_item_toggled_cb (
308 BonoboUIComponent *ui_component,
310 Bonobo_UIComponent_EventType type,
316 gl_debug (DEBUG_MDI, "%s toggled to '%s'", path, state);
318 s = (strcmp (state, "1") == 0);
320 if ((strcmp (path, "ViewToolbar") == 0) &&
321 (s != gl_prefs->toolbar_visible))
323 gl_prefs->toolbar_visible = s;
324 gl_mdi_set_app_toolbar_style (win);
329 if (s && (strcmp (path, "ToolbarSystem") == 0) &&
330 (gl_prefs->toolbar_buttons_style != GL_TOOLBAR_SYSTEM))
332 gl_prefs->toolbar_buttons_style = GL_TOOLBAR_SYSTEM;
333 gl_mdi_set_app_toolbar_style (win);
338 if (s && (strcmp (path, "ToolbarIcon") == 0) &&
339 (gl_prefs->toolbar_buttons_style != GL_TOOLBAR_ICONS))
341 gl_prefs->toolbar_buttons_style = GL_TOOLBAR_ICONS;
342 gl_mdi_set_app_toolbar_style (win);
347 if (s && (strcmp (path, "ToolbarIconText") == 0) &&
348 (gl_prefs->toolbar_buttons_style != GL_TOOLBAR_ICONS_AND_TEXT))
350 gl_prefs->toolbar_buttons_style = GL_TOOLBAR_ICONS_AND_TEXT;
351 gl_mdi_set_app_toolbar_style (win);
356 if ((strcmp (path, "ToolbarTooltips") == 0) &&
357 (s != gl_prefs->toolbar_view_tooltips))
359 gl_prefs->toolbar_view_tooltips = s;
360 gl_mdi_set_app_toolbar_style (win);
367 /*---------------------------------------------------------------------------*/
368 /* Set toolbar style. */
369 /*---------------------------------------------------------------------------*/
371 gl_mdi_set_app_toolbar_style (BonoboWindow *win)
373 BonoboUIComponent *ui_component;
377 gl_debug (DEBUG_MDI, "START");
379 g_return_if_fail (BONOBO_IS_WINDOW (win));
381 ui_component = bonobo_mdi_get_ui_component_from_window (win);
382 g_return_if_fail (ui_component != NULL);
384 bonobo_ui_component_freeze (ui_component, NULL);
386 /* Updated view menu */
387 gl_ui_set_verb_state (ui_component,
388 "/commands/ViewToolbar",
389 gl_prefs->toolbar_visible);
391 gl_ui_set_verb_sensitive (ui_component,
392 "/commands/ToolbarSystem",
393 gl_prefs->toolbar_visible);
394 gl_ui_set_verb_sensitive (ui_component,
395 "/commands/ToolbarIcon",
396 gl_prefs->toolbar_visible);
397 gl_ui_set_verb_sensitive (ui_component,
398 "/commands/ToolbarIconText",
399 gl_prefs->toolbar_visible);
400 gl_ui_set_verb_sensitive (ui_component,
401 "/commands/ToolbarTooltips",
402 gl_prefs->toolbar_visible);
404 gl_ui_set_verb_state (ui_component,
405 "/commands/ToolbarSystem",
406 gl_prefs->toolbar_buttons_style == GL_TOOLBAR_SYSTEM);
408 gl_ui_set_verb_state (ui_component,
409 "/commands/ToolbarIcon",
410 gl_prefs->toolbar_buttons_style == GL_TOOLBAR_ICONS);
412 gl_ui_set_verb_state (ui_component,
413 "/commands/ToolbarIconText",
414 gl_prefs->toolbar_buttons_style == GL_TOOLBAR_ICONS_AND_TEXT);
416 gl_ui_set_verb_state (ui_component,
417 "/commands/ToolbarTooltips",
418 gl_prefs->toolbar_view_tooltips);
421 /* Actually update toolbar style */
422 bonobo_ui_component_set_prop (
423 ui_component, "/Toolbar",
424 "tips", gl_prefs->toolbar_view_tooltips ? "1" : "0",
427 switch (gl_prefs->toolbar_buttons_style)
429 case GL_TOOLBAR_SYSTEM:
431 client = gconf_client_get_default ();
435 labels = gconf_client_get_bool (client,
436 "/desktop/gnome/interface/toolbar-labels", NULL);
438 g_object_unref (G_OBJECT (client));
442 gl_debug (DEBUG_MDI, "SYSTEM: BOTH");
443 bonobo_ui_component_set_prop (
444 ui_component, "/Toolbar", "look", "both", NULL);
449 gl_debug (DEBUG_MDI, "SYSTEM: ICONS");
450 bonobo_ui_component_set_prop (
451 ui_component, "/Toolbar", "look", "icons", NULL);
456 case GL_TOOLBAR_ICONS:
457 gl_debug (DEBUG_MDI, "GLABELS: ICONS");
458 bonobo_ui_component_set_prop (
459 ui_component, "/Toolbar", "look", "icon", NULL);
463 case GL_TOOLBAR_ICONS_AND_TEXT:
464 gl_debug (DEBUG_MDI, "GLABELS: ICONS_AND_TEXT");
465 bonobo_ui_component_set_prop (
466 ui_component, "/Toolbar", "look", "both", NULL);
474 bonobo_ui_component_set_prop (
475 ui_component, "/Toolbar",
476 "hidden", gl_prefs->toolbar_visible ? "0":"1", NULL);
479 bonobo_ui_component_thaw (ui_component, NULL);
481 gl_debug (DEBUG_MDI, "END");
485 /*---------------------------------------------------------------------------*/
486 /* Child state changed callback. */
487 /*---------------------------------------------------------------------------*/
489 gl_mdi_child_state_changed_cb (glMDIChild *child)
491 gl_debug (DEBUG_MDI, "START");
493 if (bonobo_mdi_get_active_child (BONOBO_MDI (glabels_mdi)) != BONOBO_MDI_CHILD (child))
496 gl_mdi_set_active_window_title (BONOBO_MDI (glabels_mdi));
497 gl_mdi_set_active_window_verbs_sensitivity (BONOBO_MDI (glabels_mdi));
499 gl_debug (DEBUG_MDI, "END");
502 /*---------------------------------------------------------------------------*/
503 /* Child undo/redo state changed callback. */
504 /*---------------------------------------------------------------------------*/
506 gl_mdi_child_undo_redo_state_changed_cb (glMDIChild *child)
508 gl_debug (DEBUG_MDI, "START");
510 if (bonobo_mdi_get_active_child (BONOBO_MDI (glabels_mdi)) != BONOBO_MDI_CHILD (child))
513 gl_mdi_set_active_window_undo_redo_verbs_sensitivity (BONOBO_MDI (glabels_mdi));
514 gl_debug (DEBUG_MDI, "END");
517 /*---------------------------------------------------------------------------*/
518 /* Add child callback. */
519 /*---------------------------------------------------------------------------*/
521 gl_mdi_add_child_cb (BonoboMDI *mdi, BonoboMDIChild *child)
523 gl_debug (DEBUG_MDI, "START");
525 g_signal_connect (G_OBJECT (child), "state_changed",
526 G_CALLBACK (gl_mdi_child_state_changed_cb),
528 g_signal_connect (G_OBJECT (child), "undo_redo_state_changed",
529 G_CALLBACK (gl_mdi_child_undo_redo_state_changed_cb),
532 gl_debug (DEBUG_MDI, "END");
536 /*---------------------------------------------------------------------------*/
537 /* View selection state changed callback. */
538 /*---------------------------------------------------------------------------*/
540 gl_mdi_view_selection_state_changed_cb (glView *view)
542 gl_debug (DEBUG_MDI, "START");
544 if (bonobo_mdi_get_active_view (BONOBO_MDI (glabels_mdi)) != GTK_WIDGET (view))
547 gl_mdi_set_active_window_selection_verbs_sensitivity (BONOBO_MDI (glabels_mdi));
548 gl_debug (DEBUG_MDI, "END");
551 /*---------------------------------------------------------------------------*/
552 /* Add view callback. */
553 /*---------------------------------------------------------------------------*/
555 gl_mdi_add_view_cb (BonoboMDI *mdi, GtkWidget *view)
557 gl_debug (DEBUG_MDI, "START");
559 g_signal_connect (G_OBJECT (view), "selection_changed",
560 G_CALLBACK (gl_mdi_view_selection_state_changed_cb),
563 gl_debug (DEBUG_MDI, "END");
567 /*---------------------------------------------------------------------------*/
568 /* Remove child callback. */
569 /*---------------------------------------------------------------------------*/
571 gl_mdi_remove_child_cb (BonoboMDI *mdi, BonoboMDIChild *child)
574 gboolean close = TRUE;
576 gl_debug (DEBUG_MDI, "START");
578 g_return_val_if_fail (child != NULL, FALSE);
579 g_return_val_if_fail (GL_MDI_CHILD (child)->label != NULL, FALSE);
581 doc = GL_MDI_CHILD (child)->label;
583 if (gl_label_is_modified (doc))
585 GtkWidget *msgbox, *w;
586 gchar *fname = NULL, *msg = NULL;
590 w = GTK_WIDGET (g_list_nth_data (bonobo_mdi_child_get_views (child), 0));
593 bonobo_mdi_set_active_view (mdi, w);
595 fname = gl_label_get_short_name (doc);
597 msg = g_strdup_printf (_("Save changes to document \"%s\" before closing?"),
600 msgbox = gl_alert_dialog_new (GTK_WINDOW (bonobo_mdi_get_active_window (mdi)),
601 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
605 _("Your changes will be lost if you don't save them."));
607 gtk_dialog_add_button (GTK_DIALOG (msgbox),
608 _("Close without saving"),
611 if (glabels_close_x_button_pressed)
613 else if (glabels_exit_button_pressed)
617 /* Delete event generated */
618 if (g_list_length (bonobo_mdi_get_windows (BONOBO_MDI (glabels_mdi))) == 1)
625 gtk_dialog_add_button (GTK_DIALOG (msgbox), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
627 gtk_dialog_add_button (GTK_DIALOG (msgbox),
631 gtk_dialog_set_default_response (GTK_DIALOG (msgbox), GTK_RESPONSE_YES);
633 gtk_window_set_resizable (GTK_WINDOW (msgbox), FALSE);
635 ret = gtk_dialog_run (GTK_DIALOG (msgbox));
637 gtk_widget_destroy (msgbox);
644 case GTK_RESPONSE_YES:
645 close = gl_file_save (GL_MDI_CHILD (child));
647 case GTK_RESPONSE_NO:
654 gl_debug (DEBUG_MDI, "CLOSE: %s", close ? "TRUE" : "FALSE");
657 /* FIXME: there is a bug if you "close all" >1 docs, don't save the document
658 * and then don't close the last one.
660 /* Disable to avoid the bug */
664 g_signal_handlers_disconnect_by_func (child,
665 G_CALLBACK (gl_mdi_child_state_changed_cb),
667 g_signal_handlers_disconnect_by_func (GTK_OBJECT (child),
668 G_CALLBACK (gl_mdi_child_undo_redo_state_changed_cb),
673 gl_debug (DEBUG_MDI, "END");
677 /*---------------------------------------------------------------------------*/
678 /* Remove view callback. */
679 /*---------------------------------------------------------------------------*/
681 gl_mdi_remove_view_cb (BonoboMDI *mdi, GtkWidget *view)
683 gl_debug (DEBUG_MDI, "");
684 gl_debug (DEBUG_MDI, "END");
689 /*****************************************************************************/
690 /* Set title of active window. */
691 /*****************************************************************************/
693 gl_mdi_set_active_window_title (BonoboMDI *mdi)
695 BonoboMDIChild* active_child = NULL;
697 gchar* docname = NULL;
700 gl_debug (DEBUG_MDI, "START");
703 active_child = bonobo_mdi_get_active_child (mdi);
704 if (active_child == NULL)
707 doc = GL_MDI_CHILD (active_child)->label;
708 g_return_if_fail (doc != NULL);
710 /* Set active window title */
711 docname = gl_label_get_short_name (doc);
712 g_return_if_fail (docname != NULL);
714 if (gl_label_is_modified (doc))
716 title = g_strdup_printf ("%s %s - glabels",
717 docname, _("(modified)"));
721 title = g_strdup_printf ("%s - glabels", docname);
725 gtk_window_set_title (GTK_WINDOW (bonobo_mdi_get_active_window (mdi)), title);
730 gl_debug (DEBUG_MDI, "END");
733 /*---------------------------------------------------------------------------*/
734 /* Child changed callback. */
735 /*---------------------------------------------------------------------------*/
737 void gl_mdi_child_changed_cb (BonoboMDI *mdi, BonoboMDIChild *old_child)
739 gl_debug (DEBUG_MDI, "START");
741 gl_mdi_set_active_window_title (mdi);
743 gl_debug (DEBUG_MDI, "END");
746 /*---------------------------------------------------------------------------*/
747 /* View changed callback. */
748 /*---------------------------------------------------------------------------*/
750 void gl_mdi_view_changed_cb (BonoboMDI *mdi, GtkWidget *old_view)
754 GtkWidget *active_view;
756 gl_debug (DEBUG_MDI, "START");
758 gl_mdi_set_active_window_verbs_sensitivity (mdi);
760 active_view = bonobo_mdi_get_active_view (mdi);
762 win = bonobo_mdi_get_active_window (mdi);
763 g_return_if_fail (win != NULL);
765 gl_debug (DEBUG_MDI, "END");
768 /*****************************************************************************/
769 /* Set sensitivity of verbs in active window. */
770 /*****************************************************************************/
772 gl_mdi_set_active_window_verbs_sensitivity (BonoboMDI *mdi)
774 /* FIXME: it is too slooooooow! - Paolo */
776 BonoboWindow *active_window = NULL;
777 BonoboMDIChild *active_child = NULL;
780 BonoboUIComponent *ui_component;
782 gl_debug (DEBUG_MDI, "START");
784 active_window = bonobo_mdi_get_active_window (mdi);
786 if (active_window == NULL)
789 ui_component = bonobo_mdi_get_ui_component_from_window (active_window);
790 g_return_if_fail (ui_component != NULL);
792 active_child = bonobo_mdi_get_active_child (mdi);
794 bonobo_ui_component_freeze (ui_component, NULL);
796 if (active_child == NULL)
798 gl_ui_set_verb_list_sensitive (ui_component,
799 gl_ui_no_docs_sensible_verbs,
805 gl_ui_set_verb_list_sensitive (ui_component,
806 gl_ui_all_sensible_verbs,
810 doc = GL_MDI_CHILD (active_child)->label;
811 g_return_if_fail (doc != NULL);
813 if (!gl_label_can_undo (doc))
814 gl_ui_set_verb_sensitive (ui_component,
815 "/commands/EditUndo",
818 if (!gl_label_can_redo (doc))
819 gl_ui_set_verb_sensitive (ui_component,
820 "/commands/EditRedo",
823 gl_ui_set_verb_list_sensitive (ui_component,
824 gl_ui_not_modified_doc_sensible_verbs,
825 gl_label_is_modified (doc));
827 view = GL_VIEW (bonobo_mdi_get_active_view (mdi));
828 g_return_if_fail (view != NULL);
830 gl_ui_set_verb_list_sensitive (ui_component,
831 gl_ui_selection_sensible_verbs,
832 !gl_view_is_selection_empty (view));
833 gl_ui_set_verb_list_sensitive (ui_component,
834 gl_ui_atomic_selection_sensible_verbs,
835 gl_view_is_selection_atomic (view));
838 bonobo_ui_component_thaw (ui_component, NULL);
840 gl_debug (DEBUG_MDI, "END");
844 /*****************************************************************************/
845 /* Set sensitivity of undo/redo verbs in active window. */
846 /*****************************************************************************/
848 gl_mdi_set_active_window_undo_redo_verbs_sensitivity (BonoboMDI *mdi)
850 BonoboWindow* active_window = NULL;
851 BonoboMDIChild* active_child = NULL;
853 BonoboUIComponent *ui_component;
855 gl_debug (DEBUG_MDI, "START");
857 active_window = bonobo_mdi_get_active_window (mdi);
858 g_return_if_fail (active_window != NULL);
860 ui_component = bonobo_mdi_get_ui_component_from_window (active_window);
861 g_return_if_fail (ui_component != NULL);
863 active_child = bonobo_mdi_get_active_child (mdi);
864 doc = GL_MDI_CHILD (active_child)->label;
865 g_return_if_fail (doc != NULL);
867 bonobo_ui_component_freeze (ui_component, NULL);
869 gl_ui_set_verb_sensitive (ui_component, "/commands/EditUndo",
870 gl_label_can_undo (doc));
872 gl_ui_set_verb_sensitive (ui_component, "/commands/EditRedo",
873 gl_label_can_redo (doc));
875 bonobo_ui_component_thaw (ui_component, NULL);
877 gl_debug (DEBUG_MDI, "END");
880 /*****************************************************************************/
881 /* Set sensitivity of selection verbs in active window. */
882 /*****************************************************************************/
884 gl_mdi_set_active_window_selection_verbs_sensitivity (BonoboMDI *mdi)
886 BonoboWindow *active_window = NULL;
888 BonoboUIComponent *ui_component;
890 gl_debug (DEBUG_MDI, "START");
892 active_window = bonobo_mdi_get_active_window (mdi);
893 g_return_if_fail (active_window != NULL);
895 ui_component = bonobo_mdi_get_ui_component_from_window (active_window);
896 g_return_if_fail (ui_component != NULL);
898 view = GL_VIEW (bonobo_mdi_get_active_view (mdi));
899 g_return_if_fail (view != NULL);
901 bonobo_ui_component_freeze (ui_component, NULL);
903 gl_ui_set_verb_list_sensitive (ui_component,
904 gl_ui_selection_sensible_verbs,
905 !gl_view_is_selection_empty (view));
906 gl_ui_set_verb_list_sensitive (ui_component,
907 gl_ui_atomic_selection_sensible_verbs,
908 gl_view_is_selection_atomic (view));
910 bonobo_ui_component_thaw (ui_component, NULL);
912 gl_debug (DEBUG_MDI, "END");