1 /*
2  * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin@dfgh.net>
3  *
4  * This file is part of NetSurf, http://www.netsurf-browser.org/
5  *
6  * NetSurf is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * NetSurf is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 #ifndef NETSURF_GTK_MENU_H_
19 #define NETSURF_GTK_MENU_H_
20 
21 #include <gtk/gtk.h>
22 
23 /**
24  * File menu item on menubar
25  */
26 struct nsgtk_file_menu {
27 	GtkMenuItem *file;
28 	GtkMenu *file_menu;
29 	GtkWidget *newwindow_menuitem;
30 	GtkWidget *newtab_menuitem;
31 	GtkWidget *openfile_menuitem;
32 	GtkWidget *closewindow_menuitem;
33 	GtkWidget *export_menuitem;
34 	struct nsgtk_export_submenu *export_submenu;
35 	GtkWidget *printpreview_menuitem;
36 	GtkWidget *print_menuitem;
37 	GtkWidget *quit_menuitem;
38 };
39 
40 struct nsgtk_edit_menu {
41 	GtkMenuItem *edit; /* Edit menu item on menubar */
42 	GtkMenu *edit_menu;
43 	GtkWidget *cut_menuitem;
44 	GtkWidget *copy_menuitem;
45 	GtkWidget *paste_menuitem;
46 	GtkWidget *delete_menuitem;
47 	GtkWidget *selectall_menuitem;
48 	GtkWidget *find_menuitem;
49 	GtkWidget *preferences_menuitem;
50 };
51 
52 struct nsgtk_view_menu {
53 	GtkMenuItem *view; /* View menu item on menubar */
54 	GtkMenu *view_menu; /* gtk menu attached to menu item */
55 
56 	GtkWidget *scaleview_menuitem;
57 	struct nsgtk_scaleview_submenu	*scaleview_submenu;
58 	GtkWidget *fullscreen_menuitem;
59 	GtkWidget *toolbars_menuitem;
60 	struct nsgtk_toolbars_submenu *toolbars_submenu;
61 	GtkWidget *tabs_menuitem;
62 	struct nsgtk_tabs_submenu *tabs_submenu;
63 	GtkWidget *savewindowsize_menuitem;
64 };
65 
66 struct nsgtk_nav_menu {
67 	GtkMenuItem *nav; /* Nav menu item on menubar */
68 	GtkMenu *nav_menu;
69 
70 	GtkWidget *back_menuitem;
71 	GtkWidget *forward_menuitem;
72 	GtkWidget *stop_menuitem;
73 	GtkWidget *reload_menuitem;
74 	GtkWidget *home_menuitem;
75 	GtkWidget *localhistory_menuitem;
76 	GtkWidget *globalhistory_menuitem;
77 	GtkWidget *addbookmarks_menuitem;
78 	GtkWidget *showbookmarks_menuitem;
79 	GtkWidget *openlocation_menuitem;
80 };
81 
82 struct nsgtk_tools_menu {
83 	GtkMenuItem  *tools; /* Tools menu item on menubar */
84 	GtkMenu	*tools_menu;
85 
86 	GtkWidget *showcookies_menuitem;
87 	GtkWidget *downloads_menuitem;
88 	GtkWidget *developer_menuitem;
89 	struct nsgtk_developer_submenu *developer_submenu;
90 };
91 
92 struct nsgtk_help_menu {
93 	GtkMenuItem *help; /* Help menu item on menubar */
94 	GtkMenu *help_menu;
95 	GtkWidget *contents_menuitem;
96 	GtkWidget *guide_menuitem;
97 	GtkWidget *info_menuitem;
98 	GtkWidget *about_menuitem;
99 };
100 
101 
102 struct nsgtk_export_submenu {
103 	GtkMenu *export_menu;
104 	GtkWidget *savepage_menuitem;
105 	GtkWidget *plaintext_menuitem;
106 	GtkWidget *pdf_menuitem;
107 };
108 
109 struct nsgtk_scaleview_submenu {
110 	GtkMenu *scaleview_menu;
111 	GtkWidget *zoomplus_menuitem;
112 	GtkWidget *zoomminus_menuitem;
113 	GtkWidget *zoomnormal_menuitem;
114 };
115 
116 struct nsgtk_tabs_submenu {
117 	GtkMenu *tabs_menu;
118 	GtkWidget *nexttab_menuitem;
119 	GtkWidget *prevtab_menuitem;
120 	GtkWidget *closetab_menuitem;
121 };
122 
123 struct nsgtk_toolbars_submenu {
124 	GtkMenu *toolbars_menu;
125 	GtkCheckMenuItem *menubar_menuitem;
126 	GtkCheckMenuItem *toolbar_menuitem;
127 	GtkWidget *customize_menuitem;
128 };
129 
130 struct nsgtk_developer_submenu {
131 	GtkMenu   *developer_menu;
132 
133 	GtkWidget *viewsource_menuitem;
134 	GtkWidget *toggledebugging_menuitem;
135 	GtkWidget *debugboxtree_menuitem;
136 	GtkWidget *debugdomtree_menuitem;
137 };
138 
139 /**
140  * main menubar
141  */
142 struct nsgtk_bar_submenu {
143 	GtkMenuBar		*bar_menu;
144 	struct nsgtk_file_menu	*file_submenu;
145 	struct nsgtk_edit_menu	*edit_submenu;
146 	struct nsgtk_view_menu	*view_submenu;
147 	struct nsgtk_nav_menu	*nav_submenu;
148 	struct nsgtk_tools_menu	*tools_submenu;
149 	struct nsgtk_help_menu	*help_submenu;
150 };
151 
152 struct nsgtk_burger_menu {
153 	GtkMenu	*burger_menu;
154 
155 	GtkWidget *file_menuitem;
156 	struct nsgtk_file_menu *file_submenu;
157 
158 	GtkWidget *edit_menuitem;
159 	struct nsgtk_edit_menu *edit_submenu;
160 
161 	GtkWidget *view_menuitem;
162 	struct nsgtk_view_menu *view_submenu;
163 
164 	GtkWidget *nav_menuitem;
165 	struct nsgtk_nav_menu *nav_submenu;
166 
167 	GtkWidget *tools_menuitem;
168 	struct nsgtk_tools_menu *tools_submenu;
169 
170 	GtkWidget *help_menuitem;
171 	struct nsgtk_help_menu *help_submenu;
172 };
173 
174 struct nsgtk_popup_menu {
175 	GtkMenu	*popup_menu;
176 
177 	/* navigation entries */
178 	GtkWidget *back_menuitem;
179 	GtkWidget *forward_menuitem;
180 	GtkWidget *stop_menuitem;
181 	GtkWidget *reload_menuitem;
182 
183 	GtkWidget *first_separator;
184 
185 	/* edit entries */
186 	GtkWidget *cut_menuitem;
187 	GtkWidget *copy_menuitem;
188 	GtkWidget *paste_menuitem;
189 
190 	GtkWidget *second_separator;
191 
192 	GtkWidget *toolbars_menuitem;
193 	struct nsgtk_toolbars_submenu *toolbars_submenu;
194 	GtkWidget *tools_menuitem;
195 	struct nsgtk_tools_menu *tools_submenu;
196 };
197 
198 struct nsgtk_link_menu {
199 	GtkMenu	*link_menu;
200 
201 	GtkWidget *opentab_menuitem;
202 	GtkWidget *openwin_menuitem;
203 
204 	GtkWidget *save_menuitem;
205 	GtkWidget *bookmark_menuitem;
206 	GtkWidget *copy_menuitem;
207 };
208 
209 
210 /**
211  * Create main menubar menu.
212  */
213 struct nsgtk_bar_submenu *nsgtk_menu_bar_create(GtkMenuShell *menubar, GtkAccelGroup *group);
214 
215 
216 /**
217  * Generate burger menu.
218  *
219  * \param accelerator group to use with menu
220  * \return new menu structure or NULL on error
221  */
222 struct nsgtk_burger_menu *nsgtk_burger_menu_create(GtkAccelGroup *group);
223 
224 
225 /**
226  * Generate right click popup menu.
227  *
228  * \param accelerator group to use with menu
229  * \return new menu structure or NULL on error
230  */
231 struct nsgtk_popup_menu *nsgtk_popup_menu_create(GtkAccelGroup *group);
232 
233 
234 /**
235  * Generate context sensitive link popup menu.
236  *
237  * \param accelerator group to use with menu
238  * \return new menu structure or NULL on error
239  */
240 struct nsgtk_link_menu *nsgtk_link_menu_create(GtkAccelGroup *group);
241 
242 
243 /**
244  * destroy bar menu
245  *
246  * destroys the gtk widgets associated with menu and frees all storage.
247  *
248  * \param menu menu to destroy
249  * \return NSERROR_OK and menu destroyed on success else error code
250  */
251 nserror nsgtk_menu_bar_destroy(struct nsgtk_bar_submenu *menu);
252 
253 
254 /**
255  * destroy burger menu
256  *
257  * destroys the gtk widgets associated with menu and frees all storage.
258  *
259  * \param menu menu to destroy
260  * \return NSERROR_OK and menu destroyed on success else error code
261  */
262 nserror nsgtk_burger_menu_destroy(struct nsgtk_burger_menu *menu);
263 
264 
265 /**
266  * destroy popup menu
267  *
268  * destroys the gtk widgets associated with menu and frees all storage.
269  *
270  * \param menu menu to destroy
271  * \return NSERROR_OK and menu destroyed on success else error code
272  */
273 nserror nsgtk_popup_menu_destroy(struct nsgtk_popup_menu *menu);
274 
275 
276 /**
277  * destroy link menu
278  *
279  * destroys the gtk widgets associated with menu and frees all storage.
280  *
281  * \param menu menu to destroy
282  * \return NSERROR_OK and menu destroyed on success else error code
283  */
284 nserror nsgtk_link_menu_destroy(struct nsgtk_link_menu *menu);
285 
286 
287 #endif
288