-
Notifications
You must be signed in to change notification settings - Fork 13
/
barebones.cc
79 lines (57 loc) · 2.02 KB
/
barebones.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// CEF3 Bare Bones
// https://github.com/aphistic/cef3barebones
//
// For some details on what this code is doing, please see
// my blog post at:
// http://blog.erikd.org/2013/01/14/chromium-embedded-framework-3-bare-bones/
//
// PLEASE READ:
// Check out the README file for information about this code.
// TLDR version: This code is not good, it's the bare minimum you need and
// it's probably not correct in many (most?) cases. It creates a window,
// loads some pages and that's it.
#include <gtk/gtk.h>
#include "include/cef_app.h"
#include "bareboneshandler.h"
CefRefPtr<BareBonesHandler> g_handler;
void destroy(void) {
// Tells CEF to quit its message loop so the application can exit.
CefQuitMessageLoop();
}
int main(int argc, char* argv[]) {
CefMainArgs main_args(argc, argv);
int exitCode = CefExecuteProcess(main_args, NULL);
if (exitCode >= 0) {
return exitCode;
}
CefSettings settings;
CefInitialize(main_args, settings, NULL);
GtkWidget* window;
GtkWidget* vbox;
GtkWidget* hbox;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "CEF3 Bare Bones");
// Set the window to 400x400
gtk_window_set_default_size(GTK_WINDOW(window), 400, 400);
vbox = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(window), vbox);
hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
g_signal_connect(window, "destroy", G_CALLBACK(destroy), NULL);
CefBrowserSettings browserSettings;
CefWindowInfo info;
g_handler = new BareBonesHandler();
info.SetAsChild(hbox);
CefBrowserHost::CreateBrowserSync(info, g_handler.get(),
"http://code.google.com", browserSettings);
CefBrowserHost::CreateBrowserSync(info, g_handler.get(),
"http://www.github.com", browserSettings);
info.SetAsChild(vbox);
CefBrowserHost::CreateBrowserSync(info, g_handler.get(),
"http://www.google.com", browserSettings);
gtk_widget_show_all(window);
CefRunMessageLoop();
CefShutdown();
return 0;
}