2011-12-23 18:36:30 +01:00
|
|
|
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
2011-10-24 22:20:52 +02:00
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string>
|
|
|
|
#include "cefclient/cefclient.h"
|
2011-12-23 18:36:30 +01:00
|
|
|
#include "include/cef_app.h"
|
|
|
|
#include "include/cef_browser.h"
|
|
|
|
#include "include/cef_frame.h"
|
|
|
|
#include "include/cef_runnable.h"
|
2012-01-10 00:46:23 +01:00
|
|
|
#include "cefclient/binding_test.h"
|
|
|
|
#include "cefclient/client_handler.h"
|
|
|
|
#include "cefclient/extension_test.h"
|
|
|
|
#include "cefclient/scheme_test.h"
|
|
|
|
#include "cefclient/string_util.h"
|
2011-10-24 22:20:52 +02:00
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
char szWorkingDir[512]; // The current working directory
|
2011-10-24 22:20:52 +02:00
|
|
|
|
|
|
|
// The global ClientHandler reference.
|
|
|
|
extern CefRefPtr<ClientHandler> g_handler;
|
|
|
|
|
|
|
|
void destroy(void) {
|
2011-12-31 02:01:42 +01:00
|
|
|
CefQuitMessageLoop();
|
2011-10-24 22:20:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TerminationSignalHandler(int signatl) {
|
2012-01-23 20:04:54 +01:00
|
|
|
destroy();
|
2011-10-24 22:20:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Callback for Debug > Get Source... menu item.
|
|
|
|
gboolean GetSourceActivated(GtkWidget* widget) {
|
2012-01-10 00:46:23 +01:00
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
|
|
|
RunGetSourceTest(g_handler->GetBrowser());
|
2011-10-24 22:20:52 +02:00
|
|
|
|
|
|
|
return FALSE; // Don't stop this message.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Callback for Debug > Get Source... menu item.
|
|
|
|
gboolean GetTextActivated(GtkWidget* widget) {
|
2012-01-10 00:46:23 +01:00
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
|
|
|
RunGetTextTest(g_handler->GetBrowser());
|
2011-10-24 22:20:52 +02:00
|
|
|
|
|
|
|
return FALSE; // Don't stop this message.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Callback for Debug > JS Binding... menu item.
|
|
|
|
gboolean JSBindngActivated(GtkWidget* widget) {
|
2012-01-10 00:46:23 +01:00
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
|
|
|
RunBindingTest(g_handler->GetBrowser());
|
2011-10-24 22:20:52 +02:00
|
|
|
|
|
|
|
return FALSE; // Don't stop this message.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Callback for Debug > JS Extension... menu item.
|
|
|
|
gboolean JSExtensionActivated(GtkWidget* widget) {
|
2012-01-10 00:46:23 +01:00
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
2011-10-24 22:20:52 +02:00
|
|
|
RunExtensionTest(g_handler->GetBrowser());
|
|
|
|
|
|
|
|
return FALSE; // Don't stop this message.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Callback for Debug > JS Execute... menu item.
|
|
|
|
gboolean JSExecuteActivated(GtkWidget* widget) {
|
2012-01-10 00:46:23 +01:00
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
2011-10-24 22:20:52 +02:00
|
|
|
RunJavaScriptExecuteTest(g_handler->GetBrowser());
|
|
|
|
|
|
|
|
return FALSE; // Don't stop this message.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Callback for Debug > Request... menu item.
|
|
|
|
gboolean RequestActivated(GtkWidget* widget) {
|
2012-01-10 00:46:23 +01:00
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
2011-10-24 22:20:52 +02:00
|
|
|
RunRequestTest(g_handler->GetBrowser());
|
|
|
|
|
|
|
|
return FALSE; // Don't stop this message.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Callback for Debug > Local Storage... menu item.
|
|
|
|
gboolean LocalStorageActivated(GtkWidget* widget) {
|
2012-01-10 00:46:23 +01:00
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
2011-10-24 22:20:52 +02:00
|
|
|
RunLocalStorageTest(g_handler->GetBrowser());
|
|
|
|
|
|
|
|
return FALSE; // Don't stop this message.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Callback for Debug > XMLHttpRequest... menu item.
|
|
|
|
gboolean XMLHttpRequestActivated(GtkWidget* widget) {
|
2012-01-10 00:46:23 +01:00
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
2011-10-24 22:20:52 +02:00
|
|
|
RunXMLHTTPRequestTest(g_handler->GetBrowser());
|
|
|
|
|
|
|
|
return FALSE; // Don't stop this message.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Callback for Debug > WebURLRequest... menu item.
|
|
|
|
gboolean WebURLRequestActivated(GtkWidget* widget) {
|
2012-01-10 00:46:23 +01:00
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
2011-10-24 22:20:52 +02:00
|
|
|
RunWebURLRequestTest(g_handler->GetBrowser());
|
|
|
|
|
|
|
|
return FALSE; // Don't stop this message.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Callback for Debug > DOM Access... menu item.
|
|
|
|
gboolean DOMAccessActivated(GtkWidget* widget) {
|
2012-01-10 00:46:23 +01:00
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
2011-10-24 22:20:52 +02:00
|
|
|
RunDOMAccessTest(g_handler->GetBrowser());
|
|
|
|
|
|
|
|
return FALSE; // Don't stop this message.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Callback for Debug > Scheme Handler... menu item.
|
|
|
|
gboolean SchemeHandlerActivated(GtkWidget* widget) {
|
2012-01-10 00:46:23 +01:00
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
2011-10-24 22:20:52 +02:00
|
|
|
RunSchemeTest(g_handler->GetBrowser());
|
|
|
|
|
|
|
|
return FALSE; // Don't stop this message.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Callback for Debug > Popup Window... menu item.
|
|
|
|
gboolean PopupWindowActivated(GtkWidget* widget) {
|
2012-01-10 00:46:23 +01:00
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
2011-10-24 22:20:52 +02:00
|
|
|
RunPopupTest(g_handler->GetBrowser());
|
|
|
|
|
|
|
|
return FALSE; // Don't stop this message.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Callback for Debug > Accelerated 2D Canvas:... menu item.
|
|
|
|
gboolean Accelerated2DCanvasActivated(GtkWidget* widget) {
|
2012-01-10 00:46:23 +01:00
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
2011-10-24 22:20:52 +02:00
|
|
|
RunAccelerated2DCanvasTest(g_handler->GetBrowser());
|
|
|
|
|
|
|
|
return FALSE; // Don't stop this message.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Callback for Debug > Accelerated Layers:... menu item.
|
|
|
|
gboolean AcceleratedLayersActivated(GtkWidget* widget) {
|
2012-01-10 00:46:23 +01:00
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
2011-10-24 22:20:52 +02:00
|
|
|
RunAcceleratedLayersTest(g_handler->GetBrowser());
|
|
|
|
|
|
|
|
return FALSE; // Don't stop this message.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Callback for Debug > WebGL:... menu item.
|
|
|
|
gboolean WebGLActivated(GtkWidget* widget) {
|
2012-01-10 00:46:23 +01:00
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
2011-10-24 22:20:52 +02:00
|
|
|
RunWebGLTest(g_handler->GetBrowser());
|
|
|
|
|
|
|
|
return FALSE; // Don't stop this message.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Callback for Debug > HTML5 Video... menu item.
|
|
|
|
gboolean HTML5VideoActivated(GtkWidget* widget) {
|
2012-01-10 00:46:23 +01:00
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
2011-10-24 22:20:52 +02:00
|
|
|
RunHTML5VideoTest(g_handler->GetBrowser());
|
|
|
|
|
|
|
|
return FALSE; // Don't stop this message.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Callback for Debug > Zoom In... menu item.
|
|
|
|
gboolean ZoomInActivated(GtkWidget* widget) {
|
2012-01-10 00:46:23 +01:00
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd()) {
|
2011-10-24 22:20:52 +02:00
|
|
|
CefRefPtr<CefBrowser> browser = g_handler->GetBrowser();
|
|
|
|
browser->SetZoomLevel(browser->GetZoomLevel() + 0.5);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE; // Don't stop this message.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Callback for Debug > Zoom Out... menu item.
|
|
|
|
gboolean ZoomOutActivated(GtkWidget* widget) {
|
2012-01-10 00:46:23 +01:00
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd()) {
|
2011-10-24 22:20:52 +02:00
|
|
|
CefRefPtr<CefBrowser> browser = g_handler->GetBrowser();
|
|
|
|
browser->SetZoomLevel(browser->GetZoomLevel() - 0.5);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE; // Don't stop this message.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Callback for Debug > Zoom Reset... menu item.
|
|
|
|
gboolean ZoomResetActivated(GtkWidget* widget) {
|
2012-01-10 00:46:23 +01:00
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd()) {
|
2011-10-24 22:20:52 +02:00
|
|
|
CefRefPtr<CefBrowser> browser = g_handler->GetBrowser();
|
|
|
|
browser->SetZoomLevel(0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE; // Don't stop this message.
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean DragDropActivated(GtkWidget* widget) {
|
2012-01-10 00:46:23 +01:00
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd()) {
|
2011-10-24 22:20:52 +02:00
|
|
|
CefRefPtr<CefBrowser> browser = g_handler->GetBrowser();
|
|
|
|
RunDragDropTest(browser);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE; // Don't stop this message.
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean ShowDevtoolsActivated(GtkWidget* widget) {
|
2012-01-10 00:46:23 +01:00
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd()) {
|
2011-10-24 22:20:52 +02:00
|
|
|
CefRefPtr<CefBrowser> browser = g_handler->GetBrowser();
|
|
|
|
browser->ShowDevTools();
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE; // Don't stop this message.
|
|
|
|
}
|
|
|
|
|
2012-04-20 22:40:53 +02:00
|
|
|
// Callback for Debug > Plugin Info... menu item.
|
|
|
|
gboolean PluginInfoActivated(GtkWidget* widget) {
|
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
|
|
|
RunPluginInfoTest(g_handler->GetBrowser());
|
|
|
|
|
|
|
|
return FALSE; // Don't stop this message.
|
|
|
|
}
|
|
|
|
|
2011-10-24 22:20:52 +02:00
|
|
|
// Callback for when you click the back button.
|
|
|
|
void BackButtonClicked(GtkButton* button) {
|
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
|
|
|
g_handler->GetBrowser()->GoBack();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Callback for when you click the forward button.
|
|
|
|
void ForwardButtonClicked(GtkButton* button) {
|
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
|
|
|
g_handler->GetBrowser()->GoForward();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Callback for when you click the stop button.
|
|
|
|
void StopButtonClicked(GtkButton* button) {
|
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
|
|
|
g_handler->GetBrowser()->StopLoad();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Callback for when you click the reload button.
|
|
|
|
void ReloadButtonClicked(GtkButton* button) {
|
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd())
|
|
|
|
g_handler->GetBrowser()->Reload();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Callback for when you press enter in the URL box.
|
|
|
|
void URLEntryActivate(GtkEntry* entry) {
|
|
|
|
if (!g_handler.get() || !g_handler->GetBrowserHwnd())
|
|
|
|
return;
|
2012-01-10 00:46:23 +01:00
|
|
|
|
2011-10-24 22:20:52 +02:00
|
|
|
const gchar* url = gtk_entry_get_text(entry);
|
|
|
|
g_handler->GetBrowser()->GetMainFrame()->LoadURL(std::string(url).c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
// GTK utility functions ----------------------------------------------
|
|
|
|
|
|
|
|
GtkWidget* AddMenuEntry(GtkWidget* menu_widget, const char* text,
|
|
|
|
GCallback callback) {
|
|
|
|
GtkWidget* entry = gtk_menu_item_new_with_label(text);
|
|
|
|
g_signal_connect(entry, "activate", callback, NULL);
|
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(menu_widget), entry);
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget* CreateMenu(GtkWidget* menu_bar, const char* text) {
|
|
|
|
GtkWidget* menu_widget = gtk_menu_new();
|
|
|
|
GtkWidget* menu_header = gtk_menu_item_new_with_label(text);
|
|
|
|
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_header), menu_widget);
|
|
|
|
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), menu_header);
|
|
|
|
return menu_widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget* CreateMenuBar() {
|
|
|
|
GtkWidget* menu_bar = gtk_menu_bar_new();
|
|
|
|
GtkWidget* debug_menu = CreateMenu(menu_bar, "Tests");
|
2012-01-10 00:46:23 +01:00
|
|
|
|
2011-10-24 22:20:52 +02:00
|
|
|
AddMenuEntry(debug_menu, "Get Source",
|
|
|
|
G_CALLBACK(GetSourceActivated));
|
|
|
|
AddMenuEntry(debug_menu, "Get Text",
|
|
|
|
G_CALLBACK(GetTextActivated));
|
|
|
|
AddMenuEntry(debug_menu, "JS Binding",
|
|
|
|
G_CALLBACK(JSBindngActivated));
|
|
|
|
AddMenuEntry(debug_menu, "JS Extension",
|
|
|
|
G_CALLBACK(JSExtensionActivated));
|
|
|
|
AddMenuEntry(debug_menu, "JS Execute",
|
|
|
|
G_CALLBACK(JSExecuteActivated));
|
|
|
|
AddMenuEntry(debug_menu, "Request",
|
|
|
|
G_CALLBACK(RequestActivated));
|
|
|
|
AddMenuEntry(debug_menu, "Local Storage",
|
|
|
|
G_CALLBACK(LocalStorageActivated));
|
|
|
|
AddMenuEntry(debug_menu, "XMLHttpRequest",
|
|
|
|
G_CALLBACK(XMLHttpRequestActivated));
|
|
|
|
AddMenuEntry(debug_menu, "DOM Access",
|
|
|
|
G_CALLBACK(DOMAccessActivated));
|
|
|
|
AddMenuEntry(debug_menu, "Scheme Handler",
|
|
|
|
G_CALLBACK(SchemeHandlerActivated));
|
|
|
|
AddMenuEntry(debug_menu, "Popup Window",
|
|
|
|
G_CALLBACK(PopupWindowActivated));
|
|
|
|
AddMenuEntry(debug_menu, "Accelerated 2D Canvas",
|
|
|
|
G_CALLBACK(Accelerated2DCanvasActivated));
|
|
|
|
AddMenuEntry(debug_menu, "Accelerated Layers",
|
|
|
|
G_CALLBACK(AcceleratedLayersActivated));
|
|
|
|
AddMenuEntry(debug_menu, "WebGL",
|
|
|
|
G_CALLBACK(WebGLActivated));
|
|
|
|
AddMenuEntry(debug_menu, "HTML5 Video",
|
|
|
|
G_CALLBACK(HTML5VideoActivated));
|
|
|
|
AddMenuEntry(debug_menu, "Zoom In",
|
|
|
|
G_CALLBACK(ZoomInActivated));
|
|
|
|
AddMenuEntry(debug_menu, "Zoom Out",
|
|
|
|
G_CALLBACK(ZoomOutActivated));
|
|
|
|
AddMenuEntry(debug_menu, "Zoom Reset",
|
|
|
|
G_CALLBACK(ZoomResetActivated));
|
|
|
|
AddMenuEntry(debug_menu, "Test DragDrop",
|
|
|
|
G_CALLBACK(DragDropActivated));
|
|
|
|
AddMenuEntry(debug_menu, "Show DevTools",
|
|
|
|
G_CALLBACK(ShowDevtoolsActivated));
|
2012-04-20 22:40:53 +02:00
|
|
|
AddMenuEntry(debug_menu, "Plugin Info",
|
|
|
|
G_CALLBACK(PluginInfoActivated));
|
2011-10-24 22:20:52 +02:00
|
|
|
|
|
|
|
return menu_bar;
|
|
|
|
}
|
|
|
|
|
|
|
|
// WebViewDelegate::TakeFocus in the test webview delegate.
|
|
|
|
static gboolean HandleFocus(GtkWidget* widget,
|
|
|
|
GdkEventFocus* focus) {
|
2012-01-10 00:46:23 +01:00
|
|
|
if (g_handler.get() && g_handler->GetBrowserHwnd()) {
|
2011-10-24 22:20:52 +02:00
|
|
|
// Give focus to the browser window.
|
|
|
|
g_handler->GetBrowser()->SetFocus(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
2012-01-10 00:46:23 +01:00
|
|
|
if (!getcwd(szWorkingDir, sizeof (szWorkingDir)))
|
2011-10-24 22:20:52 +02:00
|
|
|
return -1;
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
GtkWidget* window;
|
2011-10-24 22:20:52 +02:00
|
|
|
|
|
|
|
gtk_init(&argc, &argv);
|
|
|
|
|
2011-11-15 00:43:52 +01:00
|
|
|
// Parse command line arguments.
|
|
|
|
AppInitCommandLine(argc, argv);
|
|
|
|
|
2011-10-24 22:20:52 +02:00
|
|
|
CefSettings settings;
|
2011-11-23 23:47:09 +01:00
|
|
|
CefRefPtr<CefApp> app;
|
2011-11-15 00:43:52 +01:00
|
|
|
|
|
|
|
// Populate the settings based on command line arguments.
|
2011-11-23 23:47:09 +01:00
|
|
|
AppGetSettings(settings, app);
|
2011-11-15 00:43:52 +01:00
|
|
|
|
2011-11-23 23:47:09 +01:00
|
|
|
// Initialize CEF.
|
|
|
|
CefInitialize(settings, app);
|
2011-10-24 22:20:52 +02:00
|
|
|
|
|
|
|
// Register the V8 extension handler.
|
|
|
|
InitExtensionTest();
|
|
|
|
|
|
|
|
// Register the scheme handler.
|
|
|
|
InitSchemeTest();
|
|
|
|
|
|
|
|
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
|
|
|
gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);
|
|
|
|
|
|
|
|
g_signal_connect(window, "focus", G_CALLBACK(&HandleFocus), NULL);
|
|
|
|
|
|
|
|
GtkWidget* vbox = gtk_vbox_new(FALSE, 0);
|
|
|
|
|
|
|
|
GtkWidget* menu_bar = CreateMenuBar();
|
|
|
|
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), menu_bar, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
GtkWidget* toolbar = gtk_toolbar_new();
|
|
|
|
// Turn off the labels on the toolbar buttons.
|
|
|
|
gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);
|
|
|
|
|
|
|
|
GtkToolItem* back = gtk_tool_button_new_from_stock(GTK_STOCK_GO_BACK);
|
|
|
|
g_signal_connect(back, "clicked",
|
|
|
|
G_CALLBACK(BackButtonClicked), NULL);
|
|
|
|
gtk_toolbar_insert(GTK_TOOLBAR(toolbar), back, -1 /* append */);
|
|
|
|
|
|
|
|
GtkToolItem* forward = gtk_tool_button_new_from_stock(GTK_STOCK_GO_FORWARD);
|
|
|
|
g_signal_connect(forward, "clicked",
|
|
|
|
G_CALLBACK(ForwardButtonClicked), NULL);
|
|
|
|
gtk_toolbar_insert(GTK_TOOLBAR(toolbar), forward, -1 /* append */);
|
|
|
|
|
|
|
|
GtkToolItem* reload = gtk_tool_button_new_from_stock(GTK_STOCK_REFRESH);
|
|
|
|
g_signal_connect(reload, "clicked",
|
|
|
|
G_CALLBACK(ReloadButtonClicked), NULL);
|
|
|
|
gtk_toolbar_insert(GTK_TOOLBAR(toolbar), reload, -1 /* append */);
|
|
|
|
|
|
|
|
GtkToolItem* stop = gtk_tool_button_new_from_stock(GTK_STOCK_STOP);
|
|
|
|
g_signal_connect(stop, "clicked",
|
|
|
|
G_CALLBACK(StopButtonClicked), NULL);
|
|
|
|
gtk_toolbar_insert(GTK_TOOLBAR(toolbar), stop, -1 /* append */);
|
|
|
|
|
|
|
|
GtkWidget* m_editWnd = gtk_entry_new();
|
|
|
|
g_signal_connect(G_OBJECT(m_editWnd), "activate",
|
|
|
|
G_CALLBACK(URLEntryActivate), NULL);
|
|
|
|
|
|
|
|
GtkToolItem* tool_item = gtk_tool_item_new();
|
|
|
|
gtk_container_add(GTK_CONTAINER(tool_item), m_editWnd);
|
|
|
|
gtk_tool_item_set_expand(tool_item, TRUE);
|
2012-01-10 00:46:23 +01:00
|
|
|
gtk_toolbar_insert(GTK_TOOLBAR(toolbar), tool_item, -1); // append
|
2011-10-24 22:20:52 +02:00
|
|
|
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
|
2012-01-10 00:46:23 +01:00
|
|
|
|
2011-10-24 22:20:52 +02:00
|
|
|
g_signal_connect(G_OBJECT(window), "destroy",
|
|
|
|
G_CALLBACK(gtk_widget_destroyed), &window);
|
|
|
|
g_signal_connect(G_OBJECT(window), "destroy",
|
|
|
|
G_CALLBACK(destroy), NULL);
|
|
|
|
|
|
|
|
// Create the handler.
|
|
|
|
g_handler = new ClientHandler();
|
|
|
|
g_handler->SetMainHwnd(vbox);
|
|
|
|
g_handler->SetEditHwnd(m_editWnd);
|
|
|
|
g_handler->SetButtonHwnds(GTK_WIDGET(back), GTK_WIDGET(forward),
|
|
|
|
GTK_WIDGET(reload), GTK_WIDGET(stop));
|
|
|
|
|
|
|
|
// Create the browser view.
|
|
|
|
CefWindowInfo window_info;
|
|
|
|
CefBrowserSettings browserSettings;
|
2011-11-15 00:43:52 +01:00
|
|
|
|
|
|
|
// Populate the settings based on command line arguments.
|
|
|
|
AppGetBrowserSettings(browserSettings);
|
|
|
|
|
2011-10-24 22:20:52 +02:00
|
|
|
window_info.SetAsChild(vbox);
|
|
|
|
|
|
|
|
CefBrowser::CreateBrowserSync(window_info,
|
|
|
|
static_cast<CefRefPtr<CefClient> >(g_handler),
|
|
|
|
"http://www.google.com", browserSettings);
|
|
|
|
|
|
|
|
gtk_container_add(GTK_CONTAINER(window), vbox);
|
|
|
|
gtk_widget_show_all(GTK_WIDGET(window));
|
|
|
|
|
|
|
|
// Install an signal handler so we clean up after ourselves.
|
|
|
|
signal(SIGINT, TerminationSignalHandler);
|
|
|
|
signal(SIGTERM, TerminationSignalHandler);
|
|
|
|
|
|
|
|
CefRunMessageLoop();
|
|
|
|
|
2011-12-31 02:01:42 +01:00
|
|
|
CefShutdown();
|
|
|
|
|
2011-10-24 22:20:52 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Global functions
|
|
|
|
|
|
|
|
std::string AppGetWorkingDirectory() {
|
|
|
|
return szWorkingDir;
|
|
|
|
}
|