]> git.sur5r.net Git - glabels/blob - src/ui.c
Fixed a few -Wall warnings
[glabels] / src / ui.c
1 /*
2  *  ui.c
3  *  Copyright (C) 2001-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 "ui.h"
24
25 #include <glib/gi18n.h>
26 #include <gconf/gconf-client.h>
27 #include <gtk/gtk.h>
28 #include <string.h>
29
30 #include "ui-util.h"
31 #include "ui-commands.h"
32 #include "file.h"
33 #include "prefs.h"
34 #include "stock.h"
35 #include "window.h"
36 #include "recent.h" 
37
38 #include "debug.h"
39
40
41 /*==========================================================================*/
42 /* Private macros and constants.                                            */
43 /*==========================================================================*/
44
45
46 /*==========================================================================*/
47 /* Private types.                                                           */
48 /*==========================================================================*/
49
50
51 /*==========================================================================*/
52 /* Local function prototypes                                                */
53 /*==========================================================================*/
54
55 static void view_ui_item_toggled_cb        (GtkToggleAction *action,
56                                             GtkUIManager    *ui);
57
58 static void set_app_main_toolbar_style     (GtkUIManager    *ui);
59
60 static void set_app_drawing_toolbar_style  (GtkUIManager    *ui);
61
62 static void set_view_style                 (GtkUIManager    *ui);
63
64 static void descend_menu_set_always_show_image (GtkMenu *menu);
65
66 static void set_additional_properties      (GtkUIManager    *ui);
67
68
69 static void connect_proxy_cb               (GtkUIManager    *ui,
70                                             GtkAction       *action,
71                                             GtkWidget       *proxy,
72                                             glWindow        *window);
73
74 static void disconnect_proxy_cb            (GtkUIManager    *ui,
75                                             GtkAction       *action,
76                                             GtkWidget       *proxy,
77                                             glWindow        *window);
78
79 static void menu_item_select_cb            (GtkMenuItem     *proxy,
80                                             glWindow        *window);
81
82 static void menu_item_deselect_cb          (GtkMenuItem     *proxy,
83                                             glWindow        *window);
84
85
86 /*==========================================================================*/
87 /* Private globals                                                          */
88 /*==========================================================================*/
89
90 static GtkActionEntry entries[] = {
91
92         /* Menu entries. */
93         { "FileMenu",                NULL, N_("_File") },
94         { "FileRecentsMenu",         NULL, N_("Open Recent _Files") },
95         { "EditMenu",                NULL, N_("_Edit") },
96         { "ViewMenu",                NULL, N_("_View") },
97         { "ViewMainToolBarMenu",     NULL, N_("Customize Main Toolbar") },
98         { "ViewDrawingToolBarMenu",  NULL, N_("Customize Drawing Toolbar") },
99         { "ViewPropertyToolBarMenu", NULL, N_("Customize Properties Toolbar") },
100         { "ObjectsMenu",             NULL, N_("_Objects") },
101         { "ObjectsCreateMenu",       NULL, N_("_Create") },
102         { "ObjectsOrderMenu",        NULL, N_("_Order") },
103         { "ObjectsRotateFlipMenu",   NULL, N_("_Rotate/Flip") },
104         { "ObjectsAlignHorizMenu",   NULL, N_("Align _Horizontal") },
105         { "ObjectsAlignVertMenu",    NULL, N_("Align _Vertical") },
106         { "HelpMenu",                NULL, N_("_Help") },
107
108         /* Popup entries. */
109         { "ContextMenu", NULL, N_("Context Menu") },
110         { "EmptySelectionContextMenu", NULL, N_("Context Menu") },
111
112         /* File action entries. */
113         { "FileNew",
114           GTK_STOCK_NEW,
115           N_("_New"),
116           "<control>N",
117           N_("Create a new file"),
118           G_CALLBACK (gl_ui_cmd_file_new) },
119
120         { "FileOpen",
121           GTK_STOCK_OPEN,
122           N_("_Open..."),
123           "<control>O",
124           N_("Open a file"),
125           G_CALLBACK (gl_ui_cmd_file_open) },
126
127         { "FileSave",
128           GTK_STOCK_SAVE,
129           N_("_Save"),
130           "<control>S",
131           N_("Save current file"),
132           G_CALLBACK (gl_ui_cmd_file_save) },
133
134         { "FileSaveAs",
135           GTK_STOCK_SAVE,
136           N_("Save _As..."),
137           "<shift><control>S",
138           N_("Save the current file to a different name"),
139           G_CALLBACK (gl_ui_cmd_file_save_as) },
140
141         { "FilePrint",
142           GTK_STOCK_PRINT,
143           N_("_Print..."),
144           "<control>P",
145           N_("Print the current file"),
146           G_CALLBACK (gl_ui_cmd_file_print) },
147
148         { "FileProperties",
149           GTK_STOCK_PROPERTIES,
150           N_("Properties..."),
151           NULL,
152           N_("Modify document properties"),
153           G_CALLBACK (gl_ui_cmd_file_properties) },
154
155         { "FileTemplateDesigner",
156           NULL,
157           N_("Template _Designer..."),
158           NULL,
159           N_("Create a custom template"),
160           G_CALLBACK (gl_ui_cmd_file_template_designer) },
161
162         { "FileClose",
163           GTK_STOCK_CLOSE,
164           N_("_Close"),
165           "<alt>F4",
166           N_("Close the current file"),
167           G_CALLBACK (gl_ui_cmd_file_close) },
168
169         { "FileQuit",
170           GTK_STOCK_QUIT,
171           N_("_Quit"),
172           "<control>Q",
173           N_("Quit the program"),
174           G_CALLBACK (gl_ui_cmd_file_quit) },
175
176
177         /* Edit action entries. */
178         { "EditUndo",
179           GTK_STOCK_UNDO,
180           N_("Undo"),
181           "<control>Z",
182           N_("Undo"),
183           G_CALLBACK (gl_ui_cmd_edit_undo) },
184
185         { "EditRedo",
186           GTK_STOCK_REDO,
187           N_("Redo"),
188           "<shift><control>Z",
189           N_("Redo"),
190           G_CALLBACK (gl_ui_cmd_edit_redo) },
191
192         { "EditCut",
193           GTK_STOCK_CUT,
194           N_("Cut"),
195           "<control>X",
196           N_("Cut the selection"),
197           G_CALLBACK (gl_ui_cmd_edit_cut) },
198
199         { "EditCopy",
200           GTK_STOCK_COPY,
201           N_("Copy"),
202           "<control>C",
203           N_("Copy the selection"),
204           G_CALLBACK (gl_ui_cmd_edit_copy) },
205
206         { "EditPaste",
207           GTK_STOCK_PASTE,
208           N_("Paste"),
209           "<control>V",
210           N_("Paste the clipboard"),
211           G_CALLBACK (gl_ui_cmd_edit_paste) },
212
213         { "EditDelete",
214           NULL,
215           N_("Delete"),
216           NULL,
217           N_("Delete the selected objects"),
218           G_CALLBACK (gl_ui_cmd_edit_delete) },
219
220         { "EditSelectAll",
221           NULL,
222           N_("Select All"),
223           "<control>A",
224           N_("Select all objects"),
225           G_CALLBACK (gl_ui_cmd_edit_select_all) },
226
227         { "EditUnSelectAll",
228           NULL,
229           N_("Un-select All"),
230           NULL,
231           N_("Remove all selections"),
232           G_CALLBACK (gl_ui_cmd_edit_unselect_all) },
233
234         { "EditPreferences",
235           GTK_STOCK_PREFERENCES,
236           N_("Preferences"),
237           NULL,
238           N_("Configure the application"),
239           G_CALLBACK (gl_ui_cmd_edit_preferences) },
240
241
242         /* View action entries. */
243         { "ViewZoomIn",
244           GTK_STOCK_ZOOM_IN,
245           N_("Zoom in"),
246           NULL,
247           N_("Increase magnification"),
248           G_CALLBACK (gl_ui_cmd_view_zoomin) },
249
250         { "ViewZoomOut",
251           GTK_STOCK_ZOOM_OUT,
252           N_("Zoom out"),
253           NULL,
254           N_("Decrease magnification"),
255           G_CALLBACK (gl_ui_cmd_view_zoomout) },
256
257         { "ViewZoom1to1",
258           GTK_STOCK_ZOOM_100,
259           N_("Zoom 1 to 1"),
260           NULL,
261           N_("Restore scale to 100%"),
262           G_CALLBACK (gl_ui_cmd_view_zoom1to1) },
263
264         { "ViewZoomToFit",
265           GTK_STOCK_ZOOM_FIT,
266           N_("Zoom to fit"),
267           NULL,
268           N_("Set scale to fit window"),
269           G_CALLBACK (gl_ui_cmd_view_zoom_to_fit) },
270
271
272         /* Objects action entries. */
273         { "ObjectsArrowMode",
274           GL_STOCK_ARROW,
275           N_("Select Mode"),
276           NULL,
277           N_("Select, move and modify objects"),
278           G_CALLBACK (gl_ui_cmd_objects_arrow_mode) },
279
280         { "ObjectsCreateText",
281           GL_STOCK_TEXT,
282           N_("Text"),
283           NULL,
284           N_("Create text object"),
285           G_CALLBACK (gl_ui_cmd_objects_create_text) },
286
287         { "ObjectsCreateBox",
288           GL_STOCK_BOX,
289           N_("Box"),
290           NULL,
291           N_("Create box/rectangle object"),
292           G_CALLBACK (gl_ui_cmd_objects_create_box) },
293
294         { "ObjectsCreateLine",
295           GL_STOCK_LINE,
296           N_("Line"),
297           NULL,
298           N_("Create line object"),
299           G_CALLBACK (gl_ui_cmd_objects_create_line) },
300
301         { "ObjectsCreateEllipse",
302           GL_STOCK_ELLIPSE,
303           N_("Ellipse"),
304           NULL,
305           N_("Create ellipse/circle object"),
306           G_CALLBACK (gl_ui_cmd_objects_create_ellipse) },
307
308         { "ObjectsCreateImage",
309           GL_STOCK_IMAGE,
310           N_("Image"),
311           NULL,
312           N_("Create image object"),
313           G_CALLBACK (gl_ui_cmd_objects_create_image) },
314
315         { "ObjectsCreateBarcode",
316           GL_STOCK_BARCODE,
317           N_("Barcode"),
318           NULL,
319           N_("Create barcode object"),
320           G_CALLBACK (gl_ui_cmd_objects_create_barcode) },
321         
322         { "ObjectsRaise",
323           GL_STOCK_ORDER_TOP,
324           N_("Bring to front"),
325           NULL,
326           N_("Raise object to top"),
327           G_CALLBACK (gl_ui_cmd_objects_raise) },
328
329         { "ObjectsLower",
330           GL_STOCK_ORDER_BOTTOM,
331           N_("Send to back"),
332           NULL,
333           N_("Lower object to bottom"),
334           G_CALLBACK (gl_ui_cmd_objects_lower) },
335
336         { "ObjectsRotateLeft",
337           GL_STOCK_ROTATE_LEFT,
338           N_("Rotate left"),
339           NULL,
340           N_("Rotate object 90 degrees counter-clockwise"),
341           G_CALLBACK (gl_ui_cmd_objects_rotate_left) },
342
343         { "ObjectsRotateRight",
344           GL_STOCK_ROTATE_RIGHT,
345           N_("Rotate right"),
346           NULL,
347           N_("Rotate object 90 degrees clockwise"),
348           G_CALLBACK (gl_ui_cmd_objects_rotate_right) },
349
350         { "ObjectsFlipHorizontal",
351           GL_STOCK_FLIP_HORIZ,
352           N_("Flip horizontally"),
353           NULL,
354           N_("Flip object horizontally"),
355           G_CALLBACK (gl_ui_cmd_objects_flip_horiz) },
356
357         { "ObjectsFlipVertical",
358           GL_STOCK_FLIP_VERT,
359           N_("Flip vertically"),
360           NULL,
361           N_("Flip object vertically"),
362           G_CALLBACK (gl_ui_cmd_objects_flip_vert) },
363
364         { "ObjectsAlignLeft",
365           GL_STOCK_ALIGN_LEFT,
366           N_("Align left"),
367           NULL,
368           N_("Align objects to left edges"),
369           G_CALLBACK (gl_ui_cmd_objects_align_left) },
370
371         { "ObjectsAlignRight",
372           GL_STOCK_ALIGN_RIGHT,
373           N_("Align right"),
374           NULL,
375           N_("Align objects to right edges"),
376           G_CALLBACK (gl_ui_cmd_objects_align_right) },
377
378         { "ObjectsAlignHCenter",
379           GL_STOCK_ALIGN_HCENTER,
380           N_("Align horizontal center"),
381           NULL,
382           N_("Align objects to horizontal centers"),
383           G_CALLBACK (gl_ui_cmd_objects_align_hcenter) },
384
385         { "ObjectsAlignTop",
386           GL_STOCK_ALIGN_TOP,
387           N_("Align tops"),
388           NULL,
389           N_("Align objects to top edges"),
390           G_CALLBACK (gl_ui_cmd_objects_align_top) },
391
392         { "ObjectsAlignBottom",
393           GL_STOCK_ALIGN_BOTTOM,
394           N_("Align bottoms"),
395           NULL,
396           N_("Align objects to bottom edges"),
397           G_CALLBACK (gl_ui_cmd_objects_align_bottom) },
398
399         { "ObjectsAlignVCenter",
400           GL_STOCK_ALIGN_VCENTER,
401           N_("Align vertical center"),
402           NULL,
403           N_("Align objects to vertical centers"),
404           G_CALLBACK (gl_ui_cmd_objects_align_vcenter) },
405
406         { "ObjectsCenterHorizontal",
407           GL_STOCK_CENTER_HORIZ,
408           N_("Center horizontally"),
409           NULL,
410           N_("Center objects to horizontal label center"),
411           G_CALLBACK (gl_ui_cmd_objects_center_horiz) },
412
413         { "ObjectsCenterVertical",
414           GL_STOCK_CENTER_VERT,
415           N_("Center vertically"),
416           NULL,
417           N_("Center objects to vertical label center"),
418           G_CALLBACK (gl_ui_cmd_objects_center_vert) },
419
420         { "ObjectsMergeProperties",
421           GL_STOCK_MERGE,
422           N_("Merge properties"),
423           NULL,
424           N_("Edit merge properties"),
425           G_CALLBACK (gl_ui_cmd_objects_merge_properties) },
426
427
428         /* Help actions entries. */
429         { "HelpContents",
430           GTK_STOCK_HELP,
431           N_("Contents"),
432           "F1",
433           N_("Open glabels manual"),
434           G_CALLBACK (gl_ui_cmd_help_contents) },
435
436         { "HelpAbout",
437           GTK_STOCK_ABOUT,
438           N_("About..."),
439           NULL,
440           N_("About glabels"),
441           G_CALLBACK (gl_ui_cmd_help_about) },
442
443 };
444 static guint n_entries = G_N_ELEMENTS (entries);
445
446 static GtkToggleActionEntry toggle_entries[] = {
447
448         { "ViewPropertyToolBar",
449           NULL,
450           N_("Property toolbar"),
451           NULL,
452           N_("Change the visibility of the property toolbar in the current window"),
453           G_CALLBACK (gl_ui_cmd_view_property_bar_toggle),
454           TRUE },
455
456         { "ViewGrid",
457           NULL,
458           N_("Grid"),
459           NULL,
460           N_("Change the visibility of the grid in the current window"),
461           G_CALLBACK (gl_ui_cmd_view_grid_toggle),
462           TRUE },
463
464         { "ViewMarkup",
465           NULL,
466           N_("Markup"),
467           NULL,
468           N_("Change the visibility of markup lines in the current window"),
469           G_CALLBACK (gl_ui_cmd_view_markup_toggle),
470           TRUE },
471
472 };
473 static guint n_toggle_entries = G_N_ELEMENTS (toggle_entries);
474
475 static GtkToggleActionEntry ui_toggle_entries[] = {
476
477         { "ViewMainToolBar",
478           NULL,
479           N_("Main toolbar"),
480           NULL,
481           N_("Change the visibility of the main toolbar in the current window"),
482           G_CALLBACK (view_ui_item_toggled_cb),
483           TRUE },
484
485         { "ViewDrawingToolBar",
486           NULL,
487           N_("Drawing toolbar"),
488           NULL,
489           N_("Change the visibility of the drawing toolbar in the current window"),
490           G_CALLBACK (view_ui_item_toggled_cb),
491           TRUE },
492
493 };
494 static guint n_ui_toggle_entries = G_N_ELEMENTS (ui_toggle_entries);
495
496 static const gchar *ui_info = 
497 "<ui>"
498 ""
499 "       <menubar name='MenuBar'>"
500 "               <menu action='FileMenu'>"
501 "                       <menuitem action='FileNew' />"
502 "                       <menuitem action='FileOpen' />"
503 "                       <menuitem action='FileRecentsMenu' />"
504 "                       <separator />"
505 "                       <menuitem action='FileSave' />"
506 "                       <menuitem action='FileSaveAs' />"
507 "                       <separator />"
508 "                       <menuitem action='FilePrint' />"
509 "                       <separator />"
510 "                       <menuitem action='FileProperties' />"
511 "                       <menuitem action='FileTemplateDesigner' />"
512 "                       <separator />"
513 "                       <menuitem action='FileClose' />"
514 "                       <menuitem action='FileQuit' />"
515 "               </menu>"
516 "               <menu action='EditMenu'>"
517 "                       <menuitem action='EditUndo' />"
518 "                       <menuitem action='EditRedo' />"
519 "                       <separator />"
520 "                       <menuitem action='EditCut' />"
521 "                       <menuitem action='EditCopy' />"
522 "                       <menuitem action='EditPaste' />"
523 "                       <menuitem action='EditDelete' />"
524 "                       <separator />"
525 "                       <menuitem action='EditSelectAll' />"
526 "                       <menuitem action='EditUnSelectAll' />"
527 "                       <separator />"
528 "                       <menuitem action='EditPreferences' />"
529 "               </menu>"
530 "               <menu action='ViewMenu'>"
531 "                       <menuitem action='ViewMainToolBar' />"
532 "                       <menuitem action='ViewDrawingToolBar' />"
533 "                       <menuitem action='ViewPropertyToolBar' />"
534 "                       <separator />"
535 "                       <menuitem action='ViewGrid' />"
536 "                       <menuitem action='ViewMarkup' />"
537 "                       <separator />"
538 "                       <menuitem action='ViewZoomIn' />"
539 "                       <menuitem action='ViewZoomOut' />"
540 "                       <menuitem action='ViewZoom1to1' />"
541 "                       <menuitem action='ViewZoomToFit' />"
542 "               </menu>"
543 "               <menu action='ObjectsMenu'>"
544 "                       <menuitem action='ObjectsArrowMode' />"
545 "                       <menu action='ObjectsCreateMenu'>"
546 "                               <menuitem action='ObjectsCreateText' />"
547 "                               <menuitem action='ObjectsCreateBox' />"
548 "                               <menuitem action='ObjectsCreateLine' />"
549 "                               <menuitem action='ObjectsCreateEllipse' />"
550 "                               <menuitem action='ObjectsCreateImage' />"
551 "                               <menuitem action='ObjectsCreateBarcode' />"
552 "                       </menu>"
553 "                       <separator />"
554 "                       <menu action='ObjectsOrderMenu'>"
555 "                               <menuitem action='ObjectsRaise' />"
556 "                               <menuitem action='ObjectsLower' />"
557 "                       </menu>"
558 "                       <menu action='ObjectsRotateFlipMenu'>"
559 "                               <menuitem action='ObjectsRotateLeft' />"
560 "                               <menuitem action='ObjectsRotateRight' />"
561 "                               <menuitem action='ObjectsFlipHorizontal' />"
562 "                               <menuitem action='ObjectsFlipVertical' />"
563 "                       </menu>"
564 "                       <menu action='ObjectsAlignHorizMenu'>"
565 "                               <menuitem action='ObjectsAlignLeft' />"
566 "                               <menuitem action='ObjectsAlignHCenter' />"
567 "                               <menuitem action='ObjectsAlignRight' />"
568 "                               <menuitem action='ObjectsCenterHorizontal' />"
569 "                       </menu>"
570 "                       <menu action='ObjectsAlignVertMenu'>"
571 "                               <menuitem action='ObjectsAlignTop' />"
572 "                               <menuitem action='ObjectsAlignVCenter' />"
573 "                               <menuitem action='ObjectsAlignBottom' />"
574 "                               <menuitem action='ObjectsCenterVertical' />"
575 "                       </menu>"
576 "                       <separator />"
577 "                       <menuitem action='ObjectsMergeProperties' />"
578 "               </menu>"
579 "               <menu action='HelpMenu'>"
580 "                       <menuitem action='HelpContents' />"
581 "                       <menuitem action='HelpAbout' />"
582 "               </menu>"
583 "       </menubar>"
584 ""
585 "       <toolbar name='MainToolBar'>"
586 "               <toolitem action='FileNew' />"
587 "               <toolitem action='FileOpen' />"
588 "               <toolitem action='FileSave' />"
589 "               <separator />"
590 "               <toolitem action='FilePrint' />"
591 "               <separator />"
592 "               <toolitem action='EditCut' />"
593 "               <toolitem action='EditCopy' />"
594 "               <toolitem action='EditPaste' />"
595 "       </toolbar>"
596 ""
597 "       <toolbar name='DrawingToolBar'>"
598 "               <toolitem action='ObjectsArrowMode' />"
599 "               <separator />"
600 "               <toolitem action='ObjectsCreateText' />"
601 "               <toolitem action='ObjectsCreateBox' />"
602 "               <toolitem action='ObjectsCreateLine' />"
603 "               <toolitem action='ObjectsCreateEllipse' />"
604 "               <toolitem action='ObjectsCreateImage' />"
605 "               <toolitem action='ObjectsCreateBarcode' />"
606 "               <separator />"
607 "               <toolitem action='ViewZoomIn' />"
608 "               <toolitem action='ViewZoomOut' />"
609 "               <toolitem action='ViewZoom1to1' />"
610 "               <toolitem action='ViewZoomToFit' />"
611 "               <separator />"
612 "               <toolitem action='ObjectsMergeProperties' />"
613 "       </toolbar>"
614 ""
615 "       <popup action='ContextMenu'>"
616 "               <menu action='ObjectsOrderMenu'>"
617 "                       <menuitem action='ObjectsRaise' />"
618 "                       <menuitem action='ObjectsLower' />"
619 "               </menu>"
620 "               <menu action='ObjectsRotateFlipMenu'>"
621 "                       <menuitem action='ObjectsRotateLeft' />"
622 "                       <menuitem action='ObjectsRotateRight' />"
623 "                       <menuitem action='ObjectsFlipHorizontal' />"
624 "                       <menuitem action='ObjectsFlipVertical' />"
625 "               </menu>"
626 "               <menu action='ObjectsAlignHorizMenu'>"
627 "                       <menuitem action='ObjectsAlignLeft' />"
628 "                       <menuitem action='ObjectsAlignHCenter' />"
629 "                       <menuitem action='ObjectsAlignRight' />"
630 "                       <menuitem action='ObjectsCenterHorizontal' />"
631 "               </menu>"
632 "               <menu action='ObjectsAlignVertMenu'>"
633 "                       <menuitem action='ObjectsAlignTop' />"
634 "                       <menuitem action='ObjectsAlignVCenter' />"
635 "                       <menuitem action='ObjectsAlignBottom' />"
636 "                       <menuitem action='ObjectsCenterVertical' />"
637 "               </menu>"
638 "               <separator />"
639 "               <menuitem action='EditCut' />"
640 "               <menuitem action='EditCopy' />"
641 "               <menuitem action='EditPaste' />"
642 "               <menuitem action='EditDelete' />"
643 "       </popup>"
644 ""
645 "       <popup action='EmptySelectionContextMenu'>"
646 "               <menuitem action='EditPaste' />"
647 "       </popup>"
648 ""
649 "</ui>";
650
651
652 static gchar* doc_verbs [] = {
653         "/ui/MenuBar/FileMenu/FileProperties",
654         "/ui/MenuBar/FileMenu/FileSave",
655         "/ui/MenuBar/FileMenu/FileSaveAs",
656         "/ui/MenuBar/FileMenu/FilePrint",
657         "/ui/MenuBar/FileMenu/FileClose",
658         "/ui/MenuBar/EditMenu/EditUndo",
659         "/ui/MenuBar/EditMenu/EditRedo",
660         "/ui/MenuBar/EditMenu/EditCut",
661         "/ui/MenuBar/EditMenu/EditCopy",
662         "/ui/MenuBar/EditMenu/EditDelete",
663         "/ui/MenuBar/EditMenu/EditSelectAll",
664         "/ui/MenuBar/EditMenu/EditUnSelectAll",
665         "/ui/MenuBar/ViewMenu/ViewZoomIn",
666         "/ui/MenuBar/ViewMenu/ViewZoomOut",
667         "/ui/MenuBar/ViewMenu/ViewZoom1to1",
668         "/ui/MenuBar/ViewMenu/ViewZoomToFit",
669         "/ui/MenuBar/ViewMenu/ViewGrid",
670         "/ui/MenuBar/ViewMenu/ViewMarkup",
671         "/ui/MenuBar/ObjectsMenu/ObjectsArrowMode",
672         "/ui/MenuBar/ObjectsMenu/ObjectsCreateMenu/ObjectsCreateText",
673         "/ui/MenuBar/ObjectsMenu/ObjectsCreateMenu/ObjectsCreateLine",
674         "/ui/MenuBar/ObjectsMenu/ObjectsCreateMenu/ObjectsCreateBox",
675         "/ui/MenuBar/ObjectsMenu/ObjectsCreateMenu/ObjectsCreateEllipse",
676         "/ui/MenuBar/ObjectsMenu/ObjectsCreateMenu/ObjectsCreateImage",
677         "/ui/MenuBar/ObjectsMenu/ObjectsCreateMenu/ObjectsCreateBarcode",
678         "/ui/MenuBar/ObjectsMenu/ObjectsOrderMenu/ObjectsRaise",
679         "/ui/MenuBar/ObjectsMenu/ObjectsOrderMenu/ObjectsLower",
680         "/ui/MenuBar/ObjectsMenu/ObjectsRotateFlipMenu/ObjectsRotateLeft",
681         "/ui/MenuBar/ObjectsMenu/ObjectsRotateFlipMenu/ObjectsRotateRight",
682         "/ui/MenuBar/ObjectsMenu/ObjectsRotateFlipMenu/ObjectsFlipHorizontal",
683         "/ui/MenuBar/ObjectsMenu/ObjectsRotateFlipMenu/ObjectsFlipVertical",
684         "/ui/MenuBar/ObjectsMenu/ObjectsAlignHorizMenu/ObjectsAlignLeft",
685         "/ui/MenuBar/ObjectsMenu/ObjectsAlignHorizMenu/ObjectsAlignRight",
686         "/ui/MenuBar/ObjectsMenu/ObjectsAlignHorizMenu/ObjectsAlignHCenter",
687         "/ui/MenuBar/ObjectsMenu/ObjectsAlignHorizMenu/ObjectsCenterHorizontal",
688         "/ui/MenuBar/ObjectsMenu/ObjectsAlignVertMenu/ObjectsAlignTop",
689         "/ui/MenuBar/ObjectsMenu/ObjectsAlignVertMenu/ObjectsAlignBottom",
690         "/ui/MenuBar/ObjectsMenu/ObjectsAlignVertMenu/ObjectsAlignVCenter",
691         "/ui/MenuBar/ObjectsMenu/ObjectsAlignVertMenu/ObjectsCenterVertical",
692         "/ui/MenuBar/ObjectsMenu/ObjectsMergeProperties",
693
694         NULL
695 };
696
697 static gchar* doc_modified_verbs [] = {
698         "/ui/MenuBar/FileMenu/FileSave",
699
700         NULL
701 };
702
703 static gchar* paste_verbs [] = {
704         "/ui/MenuBar/EditMenu/EditPaste",
705
706         NULL
707 };
708
709 static gchar* selection_verbs [] = {
710         "/ui/MenuBar/EditMenu/EditCut",
711         "/ui/MenuBar/EditMenu/EditCopy",
712         "/ui/MenuBar/EditMenu/EditDelete",
713         "/ui/MenuBar/EditMenu/EditUnSelectAll",
714         "/ui/MenuBar/ObjectsMenu/ObjectsOrderMenu/ObjectsRaise",
715         "/ui/MenuBar/ObjectsMenu/ObjectsOrderMenu/ObjectsLower",
716         "/ui/MenuBar/ObjectsMenu/ObjectsRotateFlipMenu/ObjectsRotateLeft",
717         "/ui/MenuBar/ObjectsMenu/ObjectsRotateFlipMenu/ObjectsRotateRight",
718         "/ui/MenuBar/ObjectsMenu/ObjectsRotateFlipMenu/ObjectsFlipHorizontal",
719         "/ui/MenuBar/ObjectsMenu/ObjectsRotateFlipMenu/ObjectsFlipVertical",
720         "/ui/MenuBar/ObjectsMenu/ObjectsAlignHorizMenu/ObjectsCenterHorizontal",
721         "/ui/MenuBar/ObjectsMenu/ObjectsAlignVertMenu/ObjectsCenterVertical",
722
723         NULL
724 };
725
726 static gchar* atomic_selection_verbs [] = {
727
728         NULL
729 };
730
731 static gchar* multi_selection_verbs [] = {
732         "/ui/MenuBar/ObjectsMenu/ObjectsAlignHorizMenu/ObjectsAlignLeft",
733         "/ui/MenuBar/ObjectsMenu/ObjectsAlignHorizMenu/ObjectsAlignRight",
734         "/ui/MenuBar/ObjectsMenu/ObjectsAlignHorizMenu/ObjectsAlignHCenter",
735         "/ui/MenuBar/ObjectsMenu/ObjectsAlignVertMenu/ObjectsAlignTop",
736         "/ui/MenuBar/ObjectsMenu/ObjectsAlignVertMenu/ObjectsAlignBottom",
737         "/ui/MenuBar/ObjectsMenu/ObjectsAlignVertMenu/ObjectsAlignVCenter",
738
739         NULL
740 };
741
742
743 /*****************************************************************************/
744 /** Initialize UI component for given window.                                */
745 /*****************************************************************************/
746 GtkUIManager *
747 gl_ui_new (glWindow *window)
748 {
749         GtkUIManager            *ui;
750         GtkActionGroup          *actions;
751         GError                  *error = NULL;
752         GtkWidget               *recent_menu;
753
754         gl_debug (DEBUG_UI, "START");
755
756         g_return_val_if_fail (window && GL_IS_WINDOW (window), NULL);
757
758         gl_debug (DEBUG_UI, "window = %p", window);
759
760         ui = gtk_ui_manager_new ();
761
762         g_signal_connect (ui, "connect_proxy",
763                           G_CALLBACK (connect_proxy_cb), window);
764         g_signal_connect (ui, "disconnect_proxy",
765                           G_CALLBACK (disconnect_proxy_cb), window);
766
767         actions = gtk_action_group_new ("Actions");
768         gtk_action_group_set_translation_domain (actions, NULL);
769         gtk_action_group_add_actions (actions, entries, n_entries, GTK_WINDOW (window));
770         gtk_action_group_add_toggle_actions (actions, 
771                                              toggle_entries, n_toggle_entries, 
772                                              window);
773         gtk_action_group_add_toggle_actions (actions, 
774                                              ui_toggle_entries, n_ui_toggle_entries, 
775                                              ui);
776
777         gtk_ui_manager_insert_action_group (ui, actions, 0);
778         gtk_window_add_accel_group (GTK_WINDOW (window), gtk_ui_manager_get_accel_group (ui));
779
780         gl_debug (DEBUG_UI, "Creating ui from string");
781         if (!gtk_ui_manager_add_ui_from_string (ui, ui_info, strlen (ui_info), &error)) {
782                 g_message ("building menus failed: %s", error->message);
783                 g_error_free (error);
784         }
785
786         /* Set the toolbar styles according to prefs */
787         set_app_main_toolbar_style (ui);
788         set_app_drawing_toolbar_style (ui);
789                 
790         /* Set view grid and markup visibility according to prefs */
791         set_view_style (ui);
792                 
793         /* add an Open Recents Submenu */
794         recent_menu  = gl_recent_create_menu ();
795         g_signal_connect (G_OBJECT (recent_menu), "item-activated",
796                           G_CALLBACK (gl_ui_cmd_file_open_recent), window);
797         gtk_menu_item_set_submenu (GTK_MENU_ITEM (gtk_ui_manager_get_widget (ui, "/MenuBar/FileMenu/FileRecentsMenu")),
798                                    recent_menu);
799
800
801         set_additional_properties (ui);
802
803         gl_ui_util_set_verb_list_sensitive (ui, doc_verbs, FALSE);
804         gl_ui_util_set_verb_list_sensitive (ui, paste_verbs, FALSE);
805
806         gl_debug (DEBUG_UI, "END");
807
808         return ui;
809 }
810
811
812 /*****************************************************************************/
813 /** Unref wrapper.                                                           */
814 /*****************************************************************************/
815 void
816 gl_ui_unref (GtkUIManager *ui)
817 {
818         gl_debug (DEBUG_UI, "START");
819
820         g_object_unref(ui);
821
822         gl_debug (DEBUG_UI, "END");
823 }
824
825
826 /*****************************************************************************/
827 /** Update all verbs of given UI component.                                  */
828 /*****************************************************************************/
829 void
830 gl_ui_update_all (GtkUIManager *ui,
831                   glView       *view)
832 {
833         glLabel *label;
834
835         gl_debug (DEBUG_UI, "START");
836
837         gl_ui_util_set_verb_list_sensitive (ui, doc_verbs, TRUE);
838
839         label = view->label;
840         g_return_if_fail (label != NULL);
841
842         gl_ui_util_set_verb_sensitive (ui, "/ui/MenuBar/EditMenu/EditUndo",
843                                        gl_label_can_undo (label));
844         gl_ui_util_set_verb_sensitive (ui, "/ui/MenuBar/EditMenu/EditRedo",
845                                        gl_label_can_redo (label));
846
847         gl_ui_util_set_verb_list_sensitive (ui, doc_modified_verbs,
848                                             gl_label_is_modified (label));
849
850         gl_ui_util_set_verb_sensitive (ui, "/ui/MenuBar/ViewMenu/ViewZoomIn",
851                                        !gl_view_is_zoom_max (view));
852         gl_ui_util_set_verb_sensitive (ui, "/ui/MenuBar/ViewMenu/ViewZoomOut",
853                                        !gl_view_is_zoom_min (view));
854
855         gl_ui_util_set_verb_list_sensitive (ui, selection_verbs,
856                                             !gl_label_is_selection_empty (label));
857
858         gl_ui_util_set_verb_list_sensitive (ui, atomic_selection_verbs,
859                                             gl_label_is_selection_atomic (label));
860
861         gl_ui_util_set_verb_list_sensitive (ui, multi_selection_verbs,
862                                             !gl_label_is_selection_empty (label)
863                                             && !gl_label_is_selection_atomic (label));
864
865         gl_debug (DEBUG_UI, "END");
866 }
867
868
869 /*****************************************************************************/
870 /** Update label modified verbs of given UI component.                       */
871 /*****************************************************************************/
872 void
873 gl_ui_update_modified_verbs (GtkUIManager *ui,
874                              glLabel      *label)
875 {
876         gl_debug (DEBUG_UI, "START");
877
878         gl_ui_util_set_verb_list_sensitive (ui, 
879                                             doc_modified_verbs,
880                                             gl_label_is_modified (label));
881
882         gl_debug (DEBUG_UI, "END");
883 }
884
885
886 /*****************************************************************************/
887 /** Update verbs associated with selection state of given UI component.      */
888 /*****************************************************************************/
889 void
890 gl_ui_update_selection_verbs (GtkUIManager *ui,
891                               glView       *view,
892                               gboolean      has_focus)
893 {
894         gl_debug (DEBUG_UI, "START");
895
896         if ( has_focus )
897         {
898                 gl_ui_util_set_verb_list_sensitive (ui, selection_verbs,
899                                                     !gl_label_is_selection_empty (view->label));
900
901                 gl_ui_util_set_verb_list_sensitive (ui, atomic_selection_verbs,
902                                                     gl_label_is_selection_atomic (view->label));
903
904                 gl_ui_util_set_verb_list_sensitive (ui, multi_selection_verbs,
905                                                     !gl_label_is_selection_empty (view->label)
906                                                     && !gl_label_is_selection_atomic (view->label));
907         }
908         else
909         {
910                 gl_ui_util_set_verb_list_sensitive (ui, selection_verbs, FALSE);
911                 gl_ui_util_set_verb_list_sensitive (ui, atomic_selection_verbs, FALSE);
912                 gl_ui_util_set_verb_list_sensitive (ui, multi_selection_verbs, FALSE);
913         }
914
915         gl_debug (DEBUG_UI, "END");
916 }
917
918
919 /*****************************************************************************/
920 /** Update verbs associated with zoom level of given UI component.           */
921 /*****************************************************************************/
922 void
923 gl_ui_update_zoom_verbs (GtkUIManager *ui,
924                          glView       *view)
925 {
926         gl_debug (DEBUG_UI, "START");
927
928         gl_ui_util_set_verb_sensitive (ui, "/ui/MenuBar/ViewMenu/ViewZoomIn",
929                                        !gl_view_is_zoom_max (view));
930         gl_ui_util_set_verb_sensitive (ui, "/ui/MenuBar/ViewMenu/ViewZoomOut",
931                                        !gl_view_is_zoom_min (view));
932
933         gl_debug (DEBUG_UI, "END");
934 }
935
936
937 /*****************************************************************************/
938 /** Update paste verbs of given UI component.                                */
939 /*****************************************************************************/
940 void
941 gl_ui_update_paste_verbs (GtkUIManager      *ui,
942                           gboolean           can_paste)
943 {
944         gl_debug (DEBUG_UI, "START");
945
946         gl_ui_util_set_verb_list_sensitive (ui, paste_verbs, can_paste);
947
948         gl_debug (DEBUG_UI, "END");
949 }
950
951
952 /*****************************************************************************/
953 /** Update undo/redo verbs of given UI component.                            */
954 /*****************************************************************************/
955 void
956 gl_ui_update_undo_redo_verbs (GtkUIManager *ui,
957                               glLabel      *label)
958 {
959         GtkWidget  *menu_item;
960         gchar      *description;
961         gchar      *menu_label;
962
963         gl_debug (DEBUG_UI, "START");
964
965         menu_item = gtk_ui_manager_get_widget (ui, "/MenuBar/EditMenu/EditUndo");
966         description = gl_label_get_undo_description (label);
967         menu_label = g_strdup_printf ("%s: %s", _("Undo"), description);
968         gtk_menu_item_set_label (GTK_MENU_ITEM (menu_item), menu_label);
969         g_free (menu_label);
970         g_free (description);
971
972         menu_item = gtk_ui_manager_get_widget (ui, "/MenuBar/EditMenu/EditRedo");
973         description = gl_label_get_redo_description (label);
974         menu_label = g_strdup_printf ("%s: %s", _("Redo"), description);
975         gtk_menu_item_set_label (GTK_MENU_ITEM (menu_item), menu_label);
976         g_free (menu_label);
977         g_free (description);
978
979         gl_ui_util_set_verb_sensitive (ui, "/ui/MenuBar/EditMenu/EditUndo",
980                                        gl_label_can_undo (label));
981
982         gl_ui_util_set_verb_sensitive (ui, "/ui/MenuBar/EditMenu/EditRedo",
983                                        gl_label_can_redo (label));
984
985         gl_debug (DEBUG_UI, "END");
986 }
987
988
989 /*---------------------------------------------------------------------------*/
990 /** PRIVATE.  View menu item toggled callback.                               */
991 /*---------------------------------------------------------------------------*/
992 static void
993 view_ui_item_toggled_cb (GtkToggleAction *action,
994                          GtkUIManager    *ui)
995 {
996         const gchar *name;
997         gboolean     state;
998
999         gl_debug (DEBUG_UI, "START");
1000
1001         g_return_if_fail (action && GTK_IS_TOGGLE_ACTION (action));
1002
1003         name  = gtk_action_get_name (GTK_ACTION (action));
1004         state = gtk_toggle_action_get_active (action);
1005
1006         gl_debug (DEBUG_UI, "Action = %s, State = %d", name, state);
1007
1008         if (strcmp (name, "ViewMainToolBar") == 0)
1009         {
1010                 gl_prefs_model_set_main_toolbar_visible (gl_prefs, state);
1011                 set_app_main_toolbar_style (ui);
1012         }
1013
1014         if (strcmp (name, "ViewDrawingToolBar") == 0)
1015         {
1016                 gl_prefs_model_set_drawing_toolbar_visible (gl_prefs, state);
1017                 set_app_drawing_toolbar_style (ui);
1018         }
1019
1020         gl_debug (DEBUG_UI, "");
1021 }
1022
1023
1024 /*---------------------------------------------------------------------------*/
1025 /** PRIVATE.  Set main toolbar style.                                        */
1026 /*---------------------------------------------------------------------------*/
1027 static void
1028 set_app_main_toolbar_style (GtkUIManager *ui)
1029 {
1030         GtkWidget *toolbar;
1031
1032         gl_debug (DEBUG_UI, "START");
1033
1034         g_return_if_fail (ui && GTK_IS_UI_MANAGER (ui));
1035                         
1036         /* Updated view menu */
1037         gl_ui_util_set_verb_state (ui, "/ui/ViewMenu/ViewMainToolBar",
1038                                    gl_prefs_model_get_main_toolbar_visible (gl_prefs));
1039
1040         toolbar = gtk_ui_manager_get_widget (ui, "/MainToolBar");
1041
1042         if (gl_prefs_model_get_main_toolbar_visible (gl_prefs)) {
1043                 gtk_widget_show_all (toolbar);
1044         } else {
1045                 gtk_widget_hide (toolbar);
1046         }
1047         
1048         gl_debug (DEBUG_UI, "END");
1049 }
1050
1051
1052 /*---------------------------------------------------------------------------*/
1053 /** PRIVATE.  Set drawing toolbar style.                                     */
1054 /*---------------------------------------------------------------------------*/
1055 static void
1056 set_app_drawing_toolbar_style (GtkUIManager *ui)
1057 {
1058         GtkWidget *toolbar;
1059
1060         gl_debug (DEBUG_UI, "START");
1061
1062         g_return_if_fail (ui && GTK_IS_UI_MANAGER (ui));
1063                         
1064         /* Updated view menu */
1065         gl_ui_util_set_verb_state (ui, "/ui/MenuBar/ViewMenu/ViewDrawingToolBar",
1066                                    gl_prefs_model_get_drawing_toolbar_visible (gl_prefs));
1067
1068         toolbar = gtk_ui_manager_get_widget (ui, "/DrawingToolBar");
1069
1070         gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
1071
1072         if (gl_prefs_model_get_drawing_toolbar_visible (gl_prefs)) {
1073                 gtk_widget_show_all (toolbar);
1074         } else {
1075                 gtk_widget_hide (toolbar);
1076         }
1077         
1078         gl_debug (DEBUG_UI, "END");
1079 }
1080
1081
1082 /*---------------------------------------------------------------------------*/
1083 /** PRIVATE.  Set visibility of grid and markup.                             */
1084 /*---------------------------------------------------------------------------*/
1085 static void
1086 set_view_style (GtkUIManager *ui)
1087 {
1088         gl_debug (DEBUG_UI, "START");
1089
1090         g_return_if_fail (ui && GTK_IS_UI_MANAGER(ui));
1091                         
1092         gl_ui_util_set_verb_state (ui, "/ui/MenuBar/ViewMenu/ViewGrid",
1093                                    gl_prefs_model_get_grid_visible (gl_prefs));
1094
1095         gl_ui_util_set_verb_state (ui, "/ui/MenuBar/ViewMenu/ViewMarkup",
1096                                    gl_prefs_model_get_markup_visible (gl_prefs));
1097
1098         gl_debug (DEBUG_UI, "END");
1099 }
1100
1101
1102 /*---------------------------------------------------------------------------*/
1103 /** PRIVATE.  Descend menu, set "always-show-image" for all image menu items.*/
1104 /*---------------------------------------------------------------------------*/
1105 static void
1106 descend_menu_set_always_show_image (GtkMenu *menu)
1107 {
1108         GList       *children, *p;
1109         GtkWidget   *submenu;
1110         GtkWidget   *menu_item;
1111
1112         children = gtk_container_get_children (GTK_CONTAINER (menu));
1113
1114         for ( p = children; p != NULL; p = p->next )
1115         {
1116                 menu_item = GTK_WIDGET (p->data);
1117
1118                 submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu_item));
1119                 if ( submenu )
1120                 {
1121                         descend_menu_set_always_show_image (GTK_MENU (submenu));
1122                 }
1123                 else if ( GTK_IS_IMAGE_MENU_ITEM (menu_item) )
1124                 {
1125                         g_object_set (menu_item, "always-show-image", TRUE, NULL);
1126                 }
1127         }
1128 }
1129
1130
1131 /*---------------------------------------------------------------------------*/
1132 /** PRIVATE.  Set additional properties.                                     */
1133 /*---------------------------------------------------------------------------*/
1134 static void
1135 set_additional_properties (GtkUIManager *ui)
1136 {
1137         GtkWidget  *menu;
1138         GtkWidget  *menu_item;
1139
1140         /*
1141          * Set "always-show-image" property for all Object menuitems.  This is
1142          * necessary because, as of Gtk-2.18, images are not shown by default
1143          * and you really need these visual cues for these menu items.
1144          */
1145         menu_item = gtk_ui_manager_get_widget (ui, "/MenuBar/ObjectsMenu/");
1146         menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu_item));
1147         descend_menu_set_always_show_image (GTK_MENU (menu));
1148
1149         menu_item = gtk_ui_manager_get_widget (ui, "/MenuBar/ObjectsMenu/ObjectsMergeProperties");
1150         g_object_set (menu_item, "always-show-image", FALSE, NULL); /* Leave this one out. */
1151
1152         menu_item = gtk_ui_manager_get_widget (ui, "/ContextMenu/ObjectsOrderMenu/");
1153         menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu_item));
1154         descend_menu_set_always_show_image (GTK_MENU (menu));
1155
1156         menu_item = gtk_ui_manager_get_widget (ui, "/ContextMenu/ObjectsRotateFlipMenu/");
1157         menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu_item));
1158         descend_menu_set_always_show_image (GTK_MENU (menu));
1159
1160         menu_item = gtk_ui_manager_get_widget (ui, "/ContextMenu/ObjectsAlignHorizMenu/");
1161         menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu_item));
1162         descend_menu_set_always_show_image (GTK_MENU (menu));
1163
1164         menu_item = gtk_ui_manager_get_widget (ui, "/ContextMenu/ObjectsAlignVertMenu/");
1165         menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu_item));
1166         descend_menu_set_always_show_image (GTK_MENU (menu));
1167 }
1168
1169
1170 /*---------------------------------------------------------------------------*/
1171 /** PRIVATE.  Connect proxy callback.                                        */
1172 /*---------------------------------------------------------------------------*/
1173 static void
1174 connect_proxy_cb (GtkUIManager *ui,
1175                   GtkAction    *action,
1176                   GtkWidget    *proxy,
1177                   glWindow     *window)
1178 {
1179         if (GTK_IS_MENU_ITEM (proxy))
1180         {
1181                 g_signal_connect (proxy, "select",
1182                                   G_CALLBACK (menu_item_select_cb), window);
1183                 g_signal_connect (proxy, "deselect",
1184                                   G_CALLBACK (menu_item_deselect_cb), window);
1185         }
1186 }
1187
1188
1189 /*---------------------------------------------------------------------------*/
1190 /** PRIVATE.  Disconnect proxy callback.                                     */
1191 /*---------------------------------------------------------------------------*/
1192 static void
1193 disconnect_proxy_cb (GtkUIManager *ui,
1194                      GtkAction    *action,
1195                      GtkWidget    *proxy,
1196                      glWindow     *window)
1197 {
1198         if (GTK_IS_MENU_ITEM (proxy))
1199         {
1200                 g_signal_handlers_disconnect_by_func
1201                         (proxy, G_CALLBACK (menu_item_select_cb), window);
1202                 g_signal_handlers_disconnect_by_func
1203                         (proxy, G_CALLBACK (menu_item_deselect_cb), window);
1204         }
1205 }
1206
1207
1208 /*---------------------------------------------------------------------------*/
1209 /** PRIVATE.  Menu item select callback.                                     */
1210 /*---------------------------------------------------------------------------*/
1211 static void
1212 menu_item_select_cb (GtkMenuItem *proxy,
1213                      glWindow    *window)
1214 {
1215         GtkAction *action;
1216         char      *message;
1217
1218         g_return_if_fail (window && GL_IS_WINDOW (window));
1219         g_return_if_fail (window->status_bar && GTK_IS_STATUSBAR (window->status_bar));
1220
1221         action = g_object_get_data (G_OBJECT (proxy),  "gtk-action");
1222         g_return_if_fail (action != NULL);
1223         
1224         g_object_get (G_OBJECT (action), "tooltip", &message, NULL);
1225         if (message)
1226         {
1227                 gtk_statusbar_push (GTK_STATUSBAR (window->status_bar),
1228                                     window->menu_tips_context_id, message);
1229                 g_free (message);
1230         }
1231 }
1232
1233
1234 /*---------------------------------------------------------------------------*/
1235 /** PRIVATE.  Menu item deselect callback.                                   */
1236 /*---------------------------------------------------------------------------*/
1237 static void
1238 menu_item_deselect_cb (GtkMenuItem *proxy,
1239                        glWindow    *window)
1240 {
1241         g_return_if_fail (window && GL_IS_WINDOW (window));
1242         g_return_if_fail (window->status_bar && GTK_IS_STATUSBAR (window->status_bar));
1243
1244         gtk_statusbar_pop (GTK_STATUSBAR (window->status_bar),
1245                            window->menu_tips_context_id);
1246 }
1247
1248
1249
1250 /*
1251  * Local Variables:       -- emacs
1252  * mode: C                -- emacs
1253  * c-basic-offset: 8      -- emacs
1254  * tab-width: 8           -- emacs
1255  * indent-tabs-mode: nil  -- emacs
1256  * End:                   -- emacs
1257  */