]> git.sur5r.net Git - glabels/blob - src/window.c
Updated Spanish translation
[glabels] / src / window.c
1 /*
2  *  window.c
3  *  Copyright (C) 2002-2009  Jim Evins <evins@snaught.com>.
4  *
5  *  This file is part of gLabels.
6  *
7  *  gLabels 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 3 of the License, or
10  *  (at your option) any later version.
11  *
12  *  gLabels 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 gLabels.  If not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #include <config.h>
22
23 #include "window.h"
24
25 #include <glib/gi18n.h>
26 #include <gtk/gtk.h>
27
28 #include "ui.h"
29 #include "ui-commands.h"
30 #include "file-util.h"
31 #include "xml-label.h"
32 #include "prefs.h"
33 #include "file.h"
34 #include "units-util.h"
35
36 #include "debug.h"
37
38
39 /*===========================================================================*/
40 /* Private macros and constants.                                             */
41 /*===========================================================================*/
42
43 #define DEFAULT_WINDOW_WIDTH  788
44 #define DEFAULT_WINDOW_HEIGHT 600
45
46 #define CURSOR_INFO_WIDTH     150
47 #define ZOOM_INFO_WIDTH        75
48
49
50 /*===========================================================================*/
51 /* Private globals                                                           */
52 /*===========================================================================*/
53
54 static GList *window_list = NULL;
55
56
57 /*===========================================================================*/
58 /* Local function prototypes                                                 */
59 /*===========================================================================*/
60
61 static void     gl_window_finalize     (GObject       *object);
62 static void     gl_window_dispose      (GObject       *object);
63
64 static void     set_window_title       (glWindow *window,
65                                         glLabel  *label);
66
67 static gboolean window_delete_event_cb (glWindow      *window,
68                                         GdkEvent      *event,
69                                         gpointer       user_data);
70
71 static void     selection_changed_cb   (glLabel       *label,
72                                         glWindow      *window);
73
74 static void   context_menu_activate_cb (glView       *view,
75                                         gint          button,
76                                         guint32       activate_time,
77                                         glWindow     *window);
78
79 static void     zoom_changed_cb        (glView        *view,
80                                         gdouble        zoom,
81                                         glWindow      *window);
82
83 static void     pointer_moved_cb       (glView        *view,
84                                         gdouble        x,
85                                         gdouble        y,
86                                         glWindow      *window);
87
88 static void     pointer_exit_cb        (glView        *view,
89                                         glWindow      *window);
90
91 static void     name_changed_cb        (glLabel       *label,
92                                         glWindow      *window);
93
94 static void     modified_changed_cb    (glLabel       *label,
95                                         glWindow      *window);
96
97 static void     clipboard_changed_cb   (GtkClipboard  *clipboard,
98                                         GdkEvent      *event,
99                                         glWindow      *window);
100
101 static void     focus_widget_changed_cb(GtkWindow     *gtk_window,
102                                         GtkWidget     *widget,
103                                         glWindow      *window);
104
105 static void     set_copy_paste_sensitivity  (glWindow      *window,
106                                              GtkWidget     *focus_widget);
107
108 static void     label_changed_cb       (glLabel       *label,
109                                         glWindow      *window);
110
111
112 /****************************************************************************/
113 /* Boilerplate Object stuff.                                                */
114 /****************************************************************************/
115 G_DEFINE_TYPE (glWindow, gl_window, GTK_TYPE_WINDOW)
116
117
118 static void
119 gl_window_class_init (glWindowClass *class)
120 {
121         GObjectClass   *object_class     = G_OBJECT_CLASS (class);
122
123         gl_debug (DEBUG_WINDOW, "START");
124
125         gl_window_parent_class = g_type_class_peek_parent (class);
126
127         object_class->finalize = gl_window_finalize;
128         object_class->dispose  = gl_window_dispose;
129
130         gl_debug (DEBUG_WINDOW, "END");
131 }
132
133
134 static void
135 gl_window_init (glWindow *window)
136 {
137         GtkWidget        *vbox1;
138         GtkUIManager     *ui;
139         GtkWidget        *status_hbox;
140
141         gl_debug (DEBUG_WINDOW, "START");
142
143         vbox1 = gtk_vbox_new (FALSE, 0);
144         gtk_container_add (GTK_CONTAINER (window), vbox1);
145
146         window->ui = ui = gl_ui_new (window);
147         gtk_box_pack_start (GTK_BOX (vbox1),
148                             gtk_ui_manager_get_widget (ui, "/MenuBar"),
149                             FALSE, FALSE, 0);
150         gtk_box_pack_start (GTK_BOX (vbox1),
151                             gtk_ui_manager_get_widget (ui, "/MainToolBar"),
152                             FALSE, FALSE, 0);
153         gtk_box_pack_start (GTK_BOX (vbox1),
154                             gtk_ui_manager_get_widget (ui, "/DrawingToolBar"),
155                             FALSE, FALSE, 0);
156
157         window->hbox = gtk_hbox_new (FALSE, 0);
158         gtk_box_pack_start (GTK_BOX (vbox1), window->hbox, TRUE, TRUE, 0);
159
160         window->sidebar = GL_UI_SIDEBAR (gl_ui_sidebar_new ());
161         gtk_box_pack_end (GTK_BOX (window->hbox), GTK_WIDGET (window->sidebar), FALSE, FALSE, 0);
162
163         window->property_bar = GL_UI_PROPERTY_BAR (gl_ui_property_bar_new ());
164         gtk_box_pack_start (GTK_BOX (vbox1), GTK_WIDGET (window->property_bar), FALSE, FALSE, 0);
165
166         status_hbox = gtk_hbox_new (FALSE, 0);
167         gtk_box_pack_start (GTK_BOX (vbox1), status_hbox, FALSE, FALSE, 0);
168
169         window->status_bar = gtk_statusbar_new ();
170         gtk_box_pack_start (GTK_BOX (status_hbox),
171                             window->status_bar,
172                             TRUE, TRUE, 0);
173         window->zoom_info = gtk_label_new (NULL);
174         gtk_widget_set_size_request (window->zoom_info, ZOOM_INFO_WIDTH, -1);
175         window->zoom_info_frame = gtk_frame_new (NULL);
176         gtk_frame_set_shadow_type (GTK_FRAME(window->zoom_info_frame), GTK_SHADOW_IN);
177         gtk_container_add (GTK_CONTAINER(window->zoom_info_frame), window->zoom_info);
178         gtk_widget_show_all (window->zoom_info_frame);
179         gtk_box_pack_end (GTK_BOX (status_hbox),
180                           window->zoom_info_frame,
181                           FALSE, FALSE, 0);
182
183         window->cursor_info = gtk_label_new (NULL);
184         gtk_widget_set_size_request (window->cursor_info, CURSOR_INFO_WIDTH, -1);
185         window->cursor_info_frame = gtk_frame_new (NULL);
186         gtk_frame_set_shadow_type (GTK_FRAME(window->cursor_info_frame), GTK_SHADOW_IN);
187         gtk_container_add (GTK_CONTAINER(window->cursor_info_frame), window->cursor_info);
188         gtk_widget_show_all (window->cursor_info_frame);
189         gtk_box_pack_end (GTK_BOX (status_hbox),
190                           window->cursor_info_frame,
191                           FALSE, FALSE, 0);
192
193         gtk_window_set_default_size (GTK_WINDOW (window),
194                                      DEFAULT_WINDOW_WIDTH,
195                                      DEFAULT_WINDOW_HEIGHT);
196
197         g_signal_connect (G_OBJECT(window), "delete-event",
198                           G_CALLBACK(window_delete_event_cb), NULL);
199         
200         window->menu_tips_context_id =
201                 gtk_statusbar_get_context_id (GTK_STATUSBAR (window->status_bar), "menu_tips");
202
203         window->print_settings = NULL;
204         window->merge_dialog = NULL;
205         window->context_menu = GTK_MENU (gtk_ui_manager_get_widget (ui, "/ContextMenu"));
206         window->empty_selection_context_menu =
207                 GTK_MENU (gtk_ui_manager_get_widget (ui, "/EmptySelectionContextMenu"));
208
209         window->view = NULL;
210
211         window_list = g_list_append (window_list, window);
212
213         gl_debug (DEBUG_WINDOW, "END");
214 }
215
216
217 static void
218 gl_window_finalize (GObject *object)
219 {
220         gl_debug (DEBUG_WINDOW, "START");
221
222         g_return_if_fail (object != NULL);
223         g_return_if_fail (GL_IS_WINDOW (object));
224
225         G_OBJECT_CLASS (gl_window_parent_class)->finalize (object);
226
227         gl_debug (DEBUG_WINDOW, "END");
228 }
229
230
231 static void
232 gl_window_dispose (GObject *object)
233 {
234         glWindow          *window;
235         GtkClipboard      *clipboard;
236
237         gl_debug (DEBUG_WINDOW, "START");
238
239         g_return_if_fail (object != NULL);
240         g_return_if_fail (GL_IS_WINDOW (object));
241
242         window = GL_WINDOW (object);
243         window_list = g_list_remove (window_list, window);
244
245         if (window->ui) {
246                 gl_ui_unref(window->ui);
247                 window->ui = NULL;
248         }
249
250         if (window->label)
251         {
252                 clipboard = gtk_widget_get_clipboard (GTK_WIDGET (window),
253                                                       GDK_SELECTION_CLIPBOARD);
254
255                 g_signal_handlers_disconnect_by_func (G_OBJECT (clipboard),
256                                                       G_CALLBACK (clipboard_changed_cb),
257                                                       window);
258
259                 g_object_unref (window->label);
260         }
261
262         if (G_OBJECT_CLASS (gl_window_parent_class)->dispose) {
263                 G_OBJECT_CLASS (gl_window_parent_class)->dispose (object);
264         }
265
266         gl_debug (DEBUG_WINDOW, "END");
267 }
268
269
270 /****************************************************************************/
271 /** Create a glabels window.                                                */
272 /****************************************************************************/
273 GtkWidget *
274 gl_window_new (void)
275 {
276         glWindow *window;
277
278         gl_debug (DEBUG_WINDOW, "START");
279
280         window = g_object_new (GL_TYPE_WINDOW,
281                                "title",    _("(none) - gLabels"),
282                                NULL);
283
284         gl_debug (DEBUG_WINDOW, "window=%p", window);
285         gl_debug (DEBUG_WINDOW, "view=%p", window->view);
286
287         gl_debug (DEBUG_WINDOW, "END");
288
289         return GTK_WIDGET(window);
290 }
291
292
293 /****************************************************************************/
294 /** Create a glabels window from a label.                                   */
295 /****************************************************************************/
296 GtkWidget*
297 gl_window_new_from_label (glLabel *label)
298 {
299         glWindow *window;
300
301         gl_debug (DEBUG_WINDOW, "START");
302
303         window = GL_WINDOW (gl_window_new ());
304
305         gl_window_set_label (window, label);
306
307         gl_debug (DEBUG_WINDOW, "END");
308
309         return GTK_WIDGET(window);
310 }
311
312
313 /****************************************************************************/
314 /** Create a glabels window from a glabels file.                            */
315 /****************************************************************************/
316 GtkWidget*
317 gl_window_new_from_file (const gchar *filename)
318 {
319         glWindow         *window;
320         glLabel          *label;
321         gchar            *abs_filename;
322         glXMLLabelStatus  status;
323
324         gl_debug (DEBUG_WINDOW, "START");
325
326         window = GL_WINDOW (gl_window_new ());
327
328         abs_filename = gl_file_util_make_absolute (filename);
329         label = gl_xml_label_open (abs_filename, &status);
330         g_free (abs_filename);
331
332         gl_window_set_label (window, label);
333
334         gl_debug (DEBUG_WINDOW, "END");
335
336         return GTK_WIDGET(window);
337 }
338
339
340 /****************************************************************************/
341 /** Is window empty?                                                        */
342 /****************************************************************************/
343 gboolean
344 gl_window_is_empty (glWindow    *window)
345 {
346         g_return_val_if_fail (GL_IS_WINDOW (window), FALSE);
347
348         gl_debug (DEBUG_WINDOW, "return %d", (window->view == NULL) );
349         return ( window->view == NULL );
350 }
351
352
353 /****************************************************************************/
354 /** Create view from label and place in window.                             */
355 /****************************************************************************/
356 void
357 gl_window_set_label (glWindow    *window,
358                      glLabel     *label)
359 {
360         gchar             *string;
361         GtkClipboard      *clipboard;
362         GtkWidget         *focus_widget;
363
364         gl_debug (DEBUG_WINDOW, "START");
365
366         g_return_if_fail (GL_IS_WINDOW (window));
367         g_return_if_fail (GL_IS_LABEL (label));
368
369         window->label = g_object_ref (label);
370
371         gl_label_clear_modified (label);
372
373         set_window_title (window, label);
374
375         if ( window->view != NULL ) {
376                 gtk_widget_destroy (window->view);
377                 window->view = NULL;
378         }
379
380         window->view = gl_view_new (label);
381         gtk_box_pack_start (GTK_BOX (window->hbox), window->view, TRUE, TRUE, 0);
382
383         gtk_widget_show_all (window->view);
384
385         gl_view_zoom_to_fit (GL_VIEW(window->view));
386
387         if (gl_prefs_model_get_grid_visible (gl_prefs)) {
388                 gl_view_show_grid (GL_VIEW(window->view));
389         } else {
390                 gl_view_hide_grid (GL_VIEW(window->view));
391         }
392
393         if (gl_prefs_model_get_markup_visible (gl_prefs)) {
394                 gl_view_show_markup (GL_VIEW(window->view));
395         } else {
396                 gl_view_hide_markup (GL_VIEW(window->view));
397         }
398
399         gl_ui_update_all (window->ui, GL_VIEW(window->view));
400
401         gl_ui_property_bar_set_label (window->property_bar, window->label);
402         gl_ui_sidebar_set_label (window->sidebar, window->label);
403
404         string = g_strdup_printf ("%3.0f%%",
405                                   100.0*gl_view_get_zoom (GL_VIEW(window->view)));
406         gtk_label_set_text (GTK_LABEL(window->zoom_info), string);
407         g_free (string);
408
409
410         clipboard = gtk_widget_get_clipboard (GTK_WIDGET (window),
411                                               GDK_SELECTION_CLIPBOARD);
412
413
414         g_signal_connect (G_OBJECT(window->label), "selection_changed",
415                           G_CALLBACK(selection_changed_cb), window);
416
417         g_signal_connect (G_OBJECT(window->view), "context_menu_activate",
418                           G_CALLBACK(context_menu_activate_cb), window);
419
420         g_signal_connect (G_OBJECT(window->view), "zoom_changed",
421                           G_CALLBACK(zoom_changed_cb), window);
422
423         g_signal_connect (G_OBJECT(window->view), "pointer_moved",
424                           G_CALLBACK(pointer_moved_cb), window);
425
426         g_signal_connect (G_OBJECT(window->view), "pointer_exit",
427                           G_CALLBACK(pointer_exit_cb), window);
428
429         g_signal_connect (G_OBJECT(label), "name_changed",
430                           G_CALLBACK(name_changed_cb), window);
431
432         g_signal_connect (G_OBJECT(label), "modified_changed",
433                           G_CALLBACK(modified_changed_cb), window);
434
435         g_signal_connect (G_OBJECT(clipboard), "owner_change",
436                           G_CALLBACK(clipboard_changed_cb), window);
437
438         g_signal_connect (G_OBJECT(window), "set_focus",
439                           G_CALLBACK(focus_widget_changed_cb), window);
440
441         /* Initialize "Paste" sensitivity. */
442         focus_widget = gtk_window_get_focus (GTK_WINDOW (window));
443         set_copy_paste_sensitivity (window, focus_widget);
444
445         g_signal_connect (G_OBJECT(label), "changed",
446                           G_CALLBACK(label_changed_cb), window);
447
448         gl_debug (DEBUG_WINDOW, "END");
449 }
450
451
452 /****************************************************************************/
453 /** Return list of glabels windows.                                         */
454 /****************************************************************************/
455 const GList *
456 gl_window_get_window_list (void)
457 {
458         gl_debug (DEBUG_WINDOW, "");
459         return window_list;
460 }
461
462
463 /*---------------------------------------------------------------------------*/
464 /** PRIVATE.  Set window title based on name and state of label.             */
465 /*---------------------------------------------------------------------------*/
466 static void 
467 set_window_title (glWindow *window,
468                   glLabel  *label)
469 {
470         gchar *name, *title;
471
472         gl_debug (DEBUG_WINDOW, "START");
473
474         g_return_if_fail (window && GL_IS_WINDOW (window));
475         g_return_if_fail (label && GL_IS_LABEL (label));
476
477         name = gl_label_get_short_name (label);
478         g_return_if_fail (name != NULL);
479
480         if (gl_label_is_modified (label)) {
481                 title = g_strdup_printf ("%s %s - gLabels",
482                                          name, _("(modified)"));
483         } else {
484                 title = g_strdup_printf ("%s - gLabels", name);
485         }
486
487         gtk_window_set_title (GTK_WINDOW(window), title);
488
489         g_free (name);
490         g_free (title);
491
492         gl_debug (DEBUG_WINDOW, "END");
493 }
494
495
496 /*-------------------------------------------------------------------------*/
497 /** PRIVATE.  Window "delete-event" callback.                              */
498 /*-------------------------------------------------------------------------*/
499 static gboolean
500 window_delete_event_cb (glWindow      *window,
501                         GdkEvent      *event,
502                         gpointer       user_data)
503 {
504         gl_debug (DEBUG_WINDOW, "START");
505
506         g_return_val_if_fail (window && GL_IS_WINDOW (window), TRUE);
507
508         gl_file_close (window);
509
510         gl_debug (DEBUG_WINDOW, "END");
511
512         return TRUE;
513 }
514
515
516 /*---------------------------------------------------------------------------*/
517 /** PRIVATE.  View "selection state changed" callback.                       */
518 /*---------------------------------------------------------------------------*/
519 static void 
520 selection_changed_cb (glLabel  *label,
521                       glWindow *window)
522 {
523         gl_debug (DEBUG_WINDOW, "START");
524
525         g_return_if_fail (label && GL_IS_LABEL (label));
526         g_return_if_fail (window && GL_IS_WINDOW (window));
527
528         gl_ui_update_selection_verbs (window->ui, GL_VIEW (window->view), TRUE);
529
530         gl_debug (DEBUG_WINDOW, "END");
531 }
532
533
534 /*---------------------------------------------------------------------------*/
535 /** PRIVATE.  View "context menu activate" callback.                         */
536 /*---------------------------------------------------------------------------*/
537 static void
538 context_menu_activate_cb (glView       *view,
539                           gint          button,
540                           guint32       activate_time,
541                           glWindow     *window)
542 {
543         gl_debug (DEBUG_WINDOW, "START");
544
545         g_return_if_fail (view && GL_IS_VIEW (view));
546         g_return_if_fail (window && GL_IS_WINDOW (window));
547
548         if (gl_label_is_selection_empty (view->label)) {
549
550                 gtk_menu_popup (GTK_MENU (window->empty_selection_context_menu),
551                                 NULL, NULL, NULL, NULL, button, activate_time);
552
553         } else {
554
555                 gtk_menu_popup (GTK_MENU (window->context_menu),
556                                 NULL, NULL, NULL, NULL, button, activate_time);
557
558         }
559
560         gl_debug (DEBUG_WINDOW, "END");
561 }
562
563
564 /*---------------------------------------------------------------------------*/
565 /** PRIVATE.  View "zoom state changed" callback.                            */
566 /*---------------------------------------------------------------------------*/
567 static void 
568 zoom_changed_cb (glView   *view,
569                  gdouble   zoom,
570                  glWindow *window)
571 {
572         gchar *string;
573
574         gl_debug (DEBUG_WINDOW, "START");
575
576         g_return_if_fail (view && GL_IS_VIEW (view));
577         g_return_if_fail (window && GL_IS_WINDOW (window));
578
579         string = g_strdup_printf ("%3.0f%%", 100.0*zoom);
580         gtk_label_set_text (GTK_LABEL(window->zoom_info), string);
581         g_free (string);
582
583         gl_ui_update_zoom_verbs (window->ui, view);
584
585         gl_debug (DEBUG_WINDOW, "END");
586 }
587
588
589 /*---------------------------------------------------------------------------*/
590 /** PRIVATE.  View "pointer moved" callback.                                 */
591 /*---------------------------------------------------------------------------*/
592 static void
593 pointer_moved_cb (glView   *view,
594                   gdouble   x,
595                   gdouble   y,
596                   glWindow *window)
597 {
598         gchar    *string;
599         lglUnits  units;
600         gdouble   units_per_point;
601         gint      units_precision;
602
603         gl_debug (DEBUG_WINDOW, "START");
604
605         g_return_if_fail (view && GL_IS_VIEW (view));
606         g_return_if_fail (window && GL_IS_WINDOW (window));
607
608         units = gl_prefs_model_get_units (gl_prefs);
609         units_per_point = lgl_units_get_units_per_point (units);
610         units_precision = gl_units_util_get_precision (units);
611
612         string = g_strdup_printf ("%.*f, %.*f",
613                                   units_precision, x*units_per_point,
614                                   units_precision, y*units_per_point);
615         gtk_label_set_text (GTK_LABEL(window->cursor_info), string);
616         g_free (string);
617
618         gl_debug (DEBUG_WINDOW, "END");
619 }
620
621
622 /*---------------------------------------------------------------------------*/
623 /** PRIVATE.  View "pointer exit" callback.                                  */
624 /*---------------------------------------------------------------------------*/
625 static void
626 pointer_exit_cb (glView   *view,
627                  glWindow *window)
628 {
629         gl_debug (DEBUG_WINDOW, "START");
630
631         g_return_if_fail (view && GL_IS_VIEW (view));
632         g_return_if_fail (window && GL_IS_WINDOW (window));
633
634         gtk_label_set_text (GTK_LABEL(window->cursor_info), "");
635
636         gl_debug (DEBUG_WINDOW, "END");
637 }
638
639
640 /*---------------------------------------------------------------------------*/
641 /** PRIVATE.  Label "name changed" callback.                                 */
642 /*---------------------------------------------------------------------------*/
643 static void 
644 name_changed_cb (glLabel  *label,
645                  glWindow *window)
646 {
647         gl_debug (DEBUG_WINDOW, "START");
648
649         g_return_if_fail (label && GL_IS_LABEL (label));
650         g_return_if_fail (window && GL_IS_WINDOW (window));
651
652         set_window_title (window, label);
653
654         gl_debug (DEBUG_WINDOW, "END");
655 }
656
657
658 /*---------------------------------------------------------------------------*/
659 /** PRIVATE.  Label "modified state changed" callback.                       */
660 /*---------------------------------------------------------------------------*/
661 static void 
662 modified_changed_cb (glLabel  *label,
663                      glWindow *window)
664 {
665         gl_debug (DEBUG_WINDOW, "START");
666
667         g_return_if_fail (label && GL_IS_LABEL (label));
668         g_return_if_fail (window && GL_IS_WINDOW (window));
669
670         set_window_title (window, label);
671
672         gl_ui_update_modified_verbs (window->ui, label);
673
674         gl_debug (DEBUG_WINDOW, "END");
675 }
676
677
678 /*---------------------------------------------------------------------------*/
679 /** PRIVATE.  Label "changed" callback.                                      */
680 /*---------------------------------------------------------------------------*/
681 static void
682 label_changed_cb (glLabel  *label,
683                   glWindow *window)
684 {
685         gl_debug (DEBUG_WINDOW, "START");
686
687         g_return_if_fail (label && GL_IS_LABEL (label));
688         g_return_if_fail (window && GL_IS_WINDOW (window));
689
690         gl_ui_update_undo_redo_verbs (window->ui, label);
691
692         gl_debug (DEBUG_WINDOW, "END");
693 }
694
695
696
697 /*---------------------------------------------------------------------------*/
698 /** PRIVATE.  Clipboard "owner change" callback.                             */
699 /*---------------------------------------------------------------------------*/
700 static void
701 clipboard_changed_cb (GtkClipboard *clipboard,
702                       GdkEvent     *event,
703                       glWindow     *window)
704 {
705         GtkWidget    *focus_widget;
706
707         gl_debug (DEBUG_WINDOW, "START");
708
709         g_return_if_fail (window && GL_IS_WINDOW (window));
710
711         focus_widget = gtk_window_get_focus (GTK_WINDOW (window));
712         set_copy_paste_sensitivity (window, focus_widget);
713
714         gl_debug (DEBUG_WINDOW, "END");
715 }
716
717
718 /*---------------------------------------------------------------------------*/
719 /** PRIVATE.  Window "set-focus" callback.                                   */
720 /*---------------------------------------------------------------------------*/
721 static void
722 focus_widget_changed_cb (GtkWindow *gtk_window,
723                          GtkWidget *widget,
724                          glWindow  *window)
725 {
726         gl_debug (DEBUG_WINDOW, "START");
727
728         g_return_if_fail (window && GL_IS_WINDOW (window));
729
730         if (widget)
731         {
732                 gl_debug (DEBUG_WINDOW, "SET-FOCUS %x %s\n",
733                           widget,
734                           G_OBJECT_TYPE_NAME (widget));
735
736                 set_copy_paste_sensitivity (window, widget);
737         }
738
739         gl_debug (DEBUG_WINDOW, "END");
740 }
741
742
743 /*---------------------------------------------------------------------------*/
744 /** PRIVATE.  Set paste sensitivity.                                         */
745 /*---------------------------------------------------------------------------*/
746 static void
747 set_copy_paste_sensitivity (glWindow  *window,
748                             GtkWidget *focus_widget)
749 {
750         gl_debug (DEBUG_WINDOW, "START");
751
752         g_return_if_fail (window && GL_IS_WINDOW (window));
753
754         if ( focus_widget == GL_VIEW(window->view)->canvas )
755         {
756                 gl_ui_update_selection_verbs (window->ui, GL_VIEW (window->view), TRUE);
757
758                 gl_ui_update_paste_verbs (window->ui, gl_label_can_paste (window->label));
759         }
760         else
761         {
762                 gl_ui_update_selection_verbs (window->ui, GL_VIEW (window->view), FALSE);
763                 gl_ui_update_paste_verbs (window->ui, FALSE);
764         }
765
766         gl_debug (DEBUG_WINDOW, "END");
767 }
768
769
770 /*
771  * Local Variables:       -- emacs
772  * mode: C                -- emacs
773  * c-basic-offset: 8      -- emacs
774  * tab-width: 8           -- emacs
775  * indent-tabs-mode: nil  -- emacs
776  * End:                   -- emacs
777  */