1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Netscape Public License
6
* Version 1.1 (the "License"); you may not use this file except in
7
* compliance with the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/NPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is mozilla.org code.
17
* The Initial Developer of the Original Code is
18
* Netscape Communications Corporation.
19
* Portions created by the Initial Developer are Copyright (C) 1998
20
* the Initial Developer. All Rights Reserved.
24
* Alternatively, the contents of this file may be used under the terms of
25
* either the GNU General Public License Version 2 or later (the "GPL"), or
26
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
* in which case the provisions of the GPL or the LGPL are applicable instead
28
* of those above. If you wish to allow use of your version of this file only
29
* under the terms of either the GPL or the LGPL, and not to allow others to
30
* use your version of this file under the terms of the NPL, indicate your
31
* decision by deleting the provisions above and replace them with the notice
32
* and other provisions required by the GPL or the LGPL. If you do not delete
33
* the provisions above, a recipient may use your version of this file under
34
* the terms of any one of the NPL, the GPL or the LGPL.
36
* ***** END LICENSE BLOCK ***** */
40
#include "gdksuperwin.h"
41
#include "gtkmozbox.h"
43
#include "nsBrowserWindow.h"
44
#include "resources.h"
49
typedef GtkItemFactoryCallback GIFC;
51
void gtk_ifactory_cb (nsBrowserWindow *nbw,
52
guint callback_action,
55
nbw->DispatchMenuItem(callback_action);
58
GtkItemFactoryEntry menu_items[] =
60
{ "/_File", nsnull, nsnull, 0, "<Branch>" },
61
{ "/File/_New Window", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_WINDOW_OPEN, nsnull },
62
{ "/File/_Open...", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_FILE_OPEN, nsnull },
63
{ "/File/_View Source", nsnull, (GIFC)gtk_ifactory_cb, VIEW_SOURCE, nsnull },
64
{ "/File/_Samples", nsnull, nsnull, 0, "<Branch>" },
65
{ "/File/Samples/demo #0", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO0, nsnull },
66
{ "/File/Samples/demo #1", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO1, nsnull },
67
{ "/File/Samples/demo #2", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO2, nsnull },
68
{ "/File/Samples/demo #3", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO3, nsnull },
69
{ "/File/Samples/demo #4", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO4, nsnull },
70
{ "/File/Samples/demo #5", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO5, nsnull },
71
{ "/File/Samples/demo #6", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO6, nsnull },
72
{ "/File/Samples/demo #7", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO7, nsnull },
73
{ "/File/Samples/demo #8", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO8, nsnull },
74
{ "/File/Samples/demo #9", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO9, nsnull },
75
{ "/File/Samples/demo #10", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO10, nsnull },
76
{ "/File/Samples/demo #11", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO11, nsnull },
77
{ "/File/Samples/demo #12", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO12, nsnull },
78
{ "/File/Samples/demo #13", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO13, nsnull },
79
{ "/File/Samples/demo #14", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO14, nsnull },
80
{ "/File/Samples/demo #15", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO15, nsnull },
81
{ "/File/Samples/demo #16", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO16, nsnull },
82
{ "/File/Samples/demo #17", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEMO17, nsnull },
83
{ "/File/_Test Sites", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_TOP100, nsnull },
84
{ "/File/XPToolkit Tests", nsnull, nsnull, 0, "<Branch>" },
85
{ "/File/XPToolkit Tests/Toolbar Test 1", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_XPTOOLKITTOOLBAR1, nsnull },
86
{ "/File/XPToolkit Tests/Tree Test 1", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_XPTOOLKITTREE1, nsnull },
87
{ "/File/sep1", nsnull, nsnull, 0, "<Separator>" },
88
{ "/File/Print Preview", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_ONE_COLUMN, nsnull },
89
{ "/File/Print", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_PRINT, nsnull },
90
{ "/File/sep2", nsnull, nsnull, 0, "<Separator>" },
91
{ "/File/_Exit", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_EXIT, nsnull },
93
{ "/_Edit", nsnull, nsnull, 0, "<Branch>" },
94
{ "/Edit/Cu_t", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_EDIT_CUT, nsnull },
95
{ "/Edit/_Copy", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_EDIT_COPY, nsnull },
96
{ "/Edit/_Paste", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_EDIT_PASTE, nsnull },
97
{ "/Edit/sep1", nsnull, nsnull, 0, "<Separator>" },
98
{ "/Edit/Select All", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_EDIT_SELECTALL, nsnull },
99
{ "/Edit/sep1", nsnull, nsnull, 0, "<Separator>" },
100
{ "/Edit/Find in Page", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_EDIT_FINDINPAGE, nsnull },
102
//#ifdef DEBUG // turning off for now
103
{ "/_Debug", nsnull, nsnull, 0, "<Branch>" },
104
{ "/Debug/_Visual Debugging", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_VISUAL_DEBUGGING,nsnull },
105
{ "/Debug/Visual _Event Debugging", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_VISUAL_EVENT_DEBUGGING,nsnull },
106
{ "/Debug/sep1", nsnull, nsnull, 0, "<Separator>" },
107
{ "/Debug/Event Debugging/Toggle Paint Flashing", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_TOGGLE_PAINT_FLASHING,nsnull },
108
{ "/Debug/Event Debugging/Toggle Paint Dumping", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_TOGGLE_PAINT_DUMPING,nsnull },
109
{ "/Debug/Event Debugging/Toggle Invalidate Dumping", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_TOGGLE_INVALIDATE_DUMPING,nsnull },
110
{ "/Debug/Event Debugging/Toggle Event Dumping", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_TOGGLE_EVENT_DUMPING,nsnull },
111
{ "/Debug/Event Debugging/sep1", nsnull, nsnull, 0, "<Separator>" },
112
{ "/Debug/Event Debugging/Toggle Motion Event Dumping", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_TOGGLE_MOTION_EVENT_DUMPING,nsnull },
113
{ "/Debug/Event Debugging/Toggle Crossing Event Dumping", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_TOGGLE_CROSSING_EVENT_DUMPING,nsnull },
114
{ "/Debug/sep1", nsnull, nsnull, 0, "<Separator>" },
115
{ "/Debug/Reflow Debugging/_Reflow Test", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_REFLOW_TEST, nsnull },
116
{ "/Debug/Reflow Debugging/Dump Reflow Stats", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEBUG_DUMP_REFLOW_TOTS, nsnull },
117
{ "/Debug/Reflow Debugging/Reflow Counts On", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DSP_REFLOW_CNTS_ON, nsnull },
118
{ "/Debug/Reflow Debugging/Reflow Counts Off", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DSP_REFLOW_CNTS_OFF, nsnull },
119
{ "/Debug/sep1", nsnull, nsnull, 0, "<Separator>" },
120
{ "/Debug/Dump _Content", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DUMP_CONTENT, nsnull },
121
{ "/Debug/Dump _Frames", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DUMP_FRAMES, nsnull },
122
{ "/Debug/Dump _Views", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DUMP_VIEWS, nsnull },
123
{ "/Debug/sep1", nsnull, nsnull, 0, "<Separator>" },
124
{ "/Debug/Dump _Style Sheets", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DUMP_STYLE_SHEETS, nsnull },
125
{ "/Debug/Dump _Style Contexts", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DUMP_STYLE_CONTEXTS, nsnull},
126
{ "/Debug/sep1", nsnull, nsnull, 0, "<Separator>" },
127
{ "/Debug/Debug Save", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEBUGSAVE, nsnull },
128
{ "/Debug/Debug Output Text", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DISPLAYTEXT, nsnull },
129
{ "/Debug/Debug Output HTML", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DISPLAYHTML, nsnull },
130
{ "/Debug/Debug Toggle Selection", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_TOGGLE_SELECTION,nsnull },
131
{ "/Debug/sep1", nsnull, nsnull, 0, "<Separator>" },
132
{ "/Debug/Debug Robot", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_DEBUGROBOT, nsnull },
133
{ "/_Style", nsnull, nsnull, 0, "<Branch>" },
134
{ "/Style/Select _Style Sheet", nsnull, nsnull, 0, "<Branch>" },
135
{ "/Style/Select Style Sheet/List Available Sheets", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SELECT_STYLE_LIST, nsnull },
136
{ "/Style/Select Style Sheet/sep1", nsnull, nsnull, 0, "<Separator>" },
137
{ "/Style/Select Style Sheet/Select Default", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SELECT_STYLE_DEFAULT, nsnull },
138
{ "/Style/Select Style Sheet/sep1", nsnull, nsnull, 0, "<Separator>" },
139
{ "/Style/Select Style Sheet/Select Alternative 1", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SELECT_STYLE_ONE, nsnull },
140
{ "/Style/Select Style Sheet/Select Alternative 2", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SELECT_STYLE_TWO, nsnull },
141
{ "/Style/Select Style Sheet/Select Alternative 3", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SELECT_STYLE_THREE, nsnull },
142
{ "/Style/Select Style Sheet/Select Alternative 4", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SELECT_STYLE_FOUR, nsnull },
143
{ "/Style/_Compatibility Mode", nsnull, nsnull, 0, "<Branch>" },
144
{ "/Style/Compatibility Mode/Use DTD", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_USE_DTD_MODE, nsnull },
145
{ "/Style/Compatibility Mode/Nav Quirks", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_NAV_QUIRKS_MODE, nsnull },
146
{ "/Style/Compatibility Mode/Standard", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_STANDARD_MODE, nsnull },
147
{ "/Style/_Gfx Scrollbars Mode", nsnull, nsnull, 0, "<Branch>" },
148
{ "/Style/Gfx Scrollbars Mode/Gfx On", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_GFX_SCROLLBARS_ON, nsnull },
149
{ "/Style/Gfx Scrollbars Mode/Gfx Off", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_GFX_SCROLLBARS_OFF, nsnull },
152
{ "/_URLs", nsnull, nsnull, 0, "<Branch>" },
153
{ "/URLs/Goto URL 1", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_GOTO_TEST_URL1,nsnull },
154
{ "/URLs/Goto URL 2", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_GOTO_TEST_URL2,nsnull },
155
{ "/URLs/sep1", nsnull, nsnull, 0, "<Separator>" },
156
{ "/URLs/Save URL 1", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SAVE_TEST_URL1,nsnull },
157
{ "/URLs/Save URL 2", nsnull, (GIFC)gtk_ifactory_cb, VIEWER_SAVE_TEST_URL2,nsnull },
159
{ "/_Tools", nsnull, nsnull, 0, "<Branch>" },
160
{ "/Tools/_JavaScript Console", nsnull, (GIFC)gtk_ifactory_cb, JS_CONSOLE, nsnull },
161
{ "/Tools/_Editor Mode", nsnull, (GIFC)gtk_ifactory_cb, EDITOR_MODE, nsnull }
164
void CreateViewerMenus(nsIWidget * aParent,
166
GtkWidget ** aMenuBarOut)
168
NS_ASSERTION(nsnull != aParent,"null parent.");
169
NS_ASSERTION(nsnull != aMenuBarOut,"null out param.");
171
GtkItemFactory *item_factory;
174
GdkSuperWin *gdkSuperWin;
177
gdkSuperWin = (GdkSuperWin*)aParent->GetNativeData(NS_NATIVE_WIDGET);
179
int nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
180
item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", nsnull);
182
gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, data);
184
menubar = gtk_item_factory_get_widget (item_factory, "<main>");
186
gtk_menu_bar_set_shadow_type (GTK_MENU_BAR(menubar), GTK_SHADOW_NONE);
188
NS_ASSERTION(GDK_IS_SUPERWIN(gdkSuperWin), "code assumes a gdksuperwin.");
189
mozBox = gtk_mozbox_new(gdkSuperWin->bin_window);
190
NS_ASSERTION((mozBox != NULL), "failed to create mozBox.");
192
gtk_container_add(GTK_CONTAINER(mozBox), menubar);
193
gtk_mozbox_set_position(GTK_MOZBOX(mozBox), 0, 0 );
194
gtk_widget_show(menubar);
195
gtk_widget_show(mozBox);
197
*aMenuBarOut = menubar;