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