panthera-www.cc
C++ source, ASCII text
1
#include "gpanthera.hh"
2
#include <gtkmm.h>
3
#include <glibmm.h>
4
#include <glibmm/ustring.h>
5
#include <iostream>
6
#include <memory>
7
#include <libintl.h>
8
#include <locale.h>
9
#include <gtk/gtk.h>
10
#include <gdk/gdk.h>
11
#include <webkit/webkit.h>
12
#include <fstream>
13
#include <nlohmann/json.hpp>
14
#include <iomanip>
15
#include <sstream>
16
#include <dlfcn.h>
17
#include "plugin_api.h"
18
19
using plugin_entrypoint_type = void(*)(void);
20
21
std::string url_encode(const std::string &value) {
22
// Thanks https://stackoverflow.com/a/17708801
23
std::ostringstream escaped;
24
escaped.fill('0');
25
escaped << std::hex;
26
27
for(char c : value) {
28
// Keep alphanumeric and other accepted characters intact
29
if (isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~') {
30
escaped << c;
31
continue;
32
}
33
34
// Any other characters are percent-encoded
35
escaped << std::uppercase;
36
escaped << '%' << std::setw(2) << int((unsigned char) c);
37
escaped << std::nouppercase;
38
}
39
40
return escaped.str();
41
}
42
43
struct SearchEngine {
44
Glib::ustring name;
45
Glib::ustring url;
46
Glib::ustring get_search_url(const std::string &query) {
47
auto pos = url.find("%s");
48
if(pos == Glib::ustring::npos) {
49
throw std::runtime_error("Invalid search engine URL: missing '%s' placeholder");
50
}
51
auto new_url = url;
52
new_url.replace(pos, 2, url_encode(query));
53
return new_url;
54
}
55
};
56
57
class PantheraWww : public Gtk::Application {
58
Gtk::Window *window = Gtk::make_managed<Gtk::Window>();
59
protected:
60
std::shared_ptr<gPanthera::LayoutManager> layout_manager;
61
std::shared_ptr<gPanthera::ContentManager> content_manager;
62
Gtk::Entry *url_bar = nullptr;
63
std::string cookie_file = "cookies.txt";
64
std::vector<SearchEngine> search_engines;
65
SearchEngine *default_search_engine = nullptr;
66
67
static void notify_callback(GObject *object, GParamSpec *pspec, gpointer data) {
68
if(!gtk_widget_get_parent(GTK_WIDGET(object))) {
69
return;
70
}
71
auto parent = gtk_widget_get_parent(gtk_widget_get_parent(GTK_WIDGET(object)));
72
if(auto page = dynamic_cast<gPanthera::ContentPage*>(Glib::wrap(parent))) {
73
if(g_strcmp0(pspec->name, "title") == 0) {
74
if(auto label = dynamic_cast<Gtk::Label*>(page->tab_widget)) {
75
label->set_label(webkit_web_view_get_title(WEBKIT_WEB_VIEW(object)));
76
}
77
}
78
}
79
}
80
81
static void notify_focused_callback(GObject *object, GParamSpec *pspec, gpointer data) {
82
if(!gtk_widget_get_parent(GTK_WIDGET(object))) {
83
return;
84
}
85
auto this_ = static_cast<PantheraWww*>(data);
86
auto parent = gtk_widget_get_parent(gtk_widget_get_parent(GTK_WIDGET(object)));
87
if(auto page = dynamic_cast<gPanthera::ContentPage*>(Glib::wrap(parent))) {
88
if(g_strcmp0(pspec->name, "uri") == 0) {
89
this_->url_bar->set_text(webkit_web_view_get_uri(WEBKIT_WEB_VIEW(object)));
90
}
91
}
92
}
93
94
static void on_back_pressed(GtkGestureClick *gesture, int n_press, double x, double y, gpointer user_data) {
95
WebKitWebView *webview = WEBKIT_WEB_VIEW(user_data);
96
webkit_web_view_go_back(webview);
97
}
98
99
static void on_forward_pressed(GtkGestureClick *gesture, int n_press, double x, double y, gpointer user_data) {
100
WebKitWebView *webview = WEBKIT_WEB_VIEW(user_data);
101
webkit_web_view_go_forward(webview);
102
}
103
104
static gboolean on_decide_policy(WebKitWebView *source, WebKitPolicyDecision *decision, WebKitPolicyDecisionType type, gpointer user_data) {
105
// Middle-click opens in a new window
106
if(auto self = static_cast<PantheraWww*>(user_data)) {
107
std::cout << type << '\n';
108
if(type == WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION) {
109
auto action = webkit_navigation_policy_decision_get_navigation_action(WEBKIT_NAVIGATION_POLICY_DECISION(decision));
110
if(webkit_navigation_action_get_mouse_button(action) == 2) {
111
Glib::ustring url = Glib::ustring(webkit_uri_request_get_uri(webkit_navigation_action_get_request(action)));
112
self->on_new_tab(nullptr, url, false);
113
webkit_policy_decision_ignore(decision);
114
return true;
115
}
116
} else if(type == WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION) {
117
auto action = webkit_navigation_policy_decision_get_navigation_action(WEBKIT_NAVIGATION_POLICY_DECISION(decision));
118
self->on_new_tab(nullptr, webkit_uri_request_get_uri(webkit_navigation_action_get_request(action)), false, true);
119
return true;
120
}
121
}
122
return false;
123
}
124
125
void on_new_tab(gPanthera::ContentStack *stack, const Glib::ustring &url = "about:blank", bool focus = true, bool new_window = false) {
126
if(!stack) {
127
// Find the current area
128
stack = content_manager->get_last_operated_page()->get_stack();
129
}
130
131
WebKitWebView *webview = WEBKIT_WEB_VIEW(webkit_web_view_new());
132
gtk_widget_set_hexpand(GTK_WIDGET(webview), true);
133
gtk_widget_set_vexpand(GTK_WIDGET(webview), true);
134
auto page_content = Gtk::make_managed<Gtk::Box>();
135
gtk_box_append(page_content->gobj(), GTK_WIDGET(webview));
136
auto page_tab = new Gtk::Label("Untitled");
137
auto page = Gtk::make_managed<gPanthera::ContentPage>(content_manager, stack, page_content, page_tab);
138
g_signal_connect(webview, "notify", G_CALLBACK(notify_callback), page->gobj());
139
g_signal_connect(webview, "decide-policy", G_CALLBACK(on_decide_policy), this);
140
webkit_web_view_load_uri(webview, url.data());
141
auto cookie_manager = webkit_network_session_get_cookie_manager(webkit_web_view_get_network_session(webview));
142
webkit_cookie_manager_set_persistent_storage(cookie_manager, cookie_file.c_str(), WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT);
143
webkit_cookie_manager_set_accept_policy(cookie_manager, WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS);
144
GtkEventController *click_controller_back = GTK_EVENT_CONTROLLER(gtk_gesture_click_new());
145
gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(click_controller_back), 8);
146
g_signal_connect(click_controller_back, "pressed", G_CALLBACK(on_back_pressed), webview);
147
gtk_widget_add_controller(GTK_WIDGET(webview), click_controller_back);
148
149
GtkEventController *click_controller_forward = GTK_EVENT_CONTROLLER(gtk_gesture_click_new());
150
gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(click_controller_forward), 9);
151
g_signal_connect(click_controller_forward, "pressed", G_CALLBACK(on_forward_pressed), webview);
152
gtk_widget_add_controller(GTK_WIDGET(webview), click_controller_forward);
153
154
stack->add_page(*page);
155
if(focus) {
156
stack->set_visible_child(*page);
157
content_manager->set_last_operated_page(page);
158
}
159
if(new_window) {
160
bool result = stack->signal_detach.emit(page);
161
}
162
}
163
164
void on_startup() override {
165
Gtk::Application::on_startup();
166
add_window(*window);
167
window->set_default_size(600, 400);
168
layout_manager = std::make_shared<gPanthera::LayoutManager>();
169
auto dock_stack_1 = Gtk::make_managed<gPanthera::DockStack>(layout_manager, "One", "one");
170
auto switcher_1 = Gtk::make_managed<gPanthera::DockStackSwitcher>(dock_stack_1, Gtk::Orientation::HORIZONTAL);
171
auto dock_stack_2 = Gtk::make_managed<gPanthera::DockStack>(layout_manager, "Two", "two");
172
auto switcher_2 = Gtk::make_managed<gPanthera::DockStackSwitcher>(dock_stack_2, Gtk::Orientation::VERTICAL);
173
auto pane_1_content = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL, 0);
174
auto debug_button = Gtk::make_managed<Gtk::Button>("Debug");
175
pane_1_content->append(*debug_button);
176
auto pane_2_content = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL, 0);
177
auto test_notebook = Gtk::make_managed<Gtk::Notebook>();
178
test_notebook->append_page(*Gtk::make_managed<Gtk::Label>("Test 1"), *Gtk::make_managed<Gtk::Label>("Test 1"));
179
pane_2_content->append(*test_notebook);
180
auto pane_3_content = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL, 0);
181
pane_3_content->append(*Gtk::make_managed<Gtk::Label>("Pane 3 content"));
182
auto pane_1_icon = Gtk::make_managed<Gtk::Image>();
183
pane_1_icon->set_from_icon_name("go-home-symbolic");
184
auto pane_2_icon = Gtk::make_managed<Gtk::Image>();
185
pane_2_icon->set_from_icon_name("folder-symbolic");
186
auto pane_3_icon = Gtk::make_managed<Gtk::Image>();
187
pane_3_icon->set_from_icon_name("network-transmit-receive-symbolic");
188
auto pane_1 = Gtk::make_managed<gPanthera::DockablePane>(layout_manager, *pane_1_content, "pane1", "Pane 1", pane_1_icon);
189
auto pane_2 = Gtk::make_managed<gPanthera::DockablePane>(layout_manager, *pane_2_content, "pane2", "Pane 2", pane_2_icon);
190
auto pane_3 = Gtk::make_managed<gPanthera::DockablePane>(layout_manager, *pane_3_content, "pane3", "Pane 3", pane_3_icon);
191
192
dock_stack_1->set_transition_type(Gtk::StackTransitionType::SLIDE_LEFT_RIGHT);
193
dock_stack_1->set_transition_duration(125);
194
dock_stack_1->set_expand(true);
195
dock_stack_2->set_transition_type(Gtk::StackTransitionType::SLIDE_UP_DOWN);
196
dock_stack_2->set_transition_duration(125);
197
dock_stack_2->set_expand(true);
198
199
auto outer_grid = Gtk::make_managed<Gtk::Grid>();
200
outer_grid->attach(*switcher_2, 0, 1, 1, 1);
201
outer_grid->attach(*switcher_1, 1, 2, 1, 1);
202
auto outer_paned = Gtk::make_managed<Gtk::Paned>(Gtk::Orientation::HORIZONTAL);
203
outer_paned->set_start_child(*dock_stack_2);
204
auto inner_paned = Gtk::make_managed<Gtk::Paned>(Gtk::Orientation::VERTICAL);
205
auto content = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL, 0);
206
content_manager = std::make_shared<gPanthera::ContentManager>();
207
std::function<bool(gPanthera::ContentPage*)> detach_handler;
208
detach_handler = [](gPanthera::ContentPage *widget) {
209
auto new_stack = Gtk::make_managed<gPanthera::ContentStack>(widget->content_manager, widget->get_stack()->get_detach_handler());
210
auto new_switcher = Gtk::make_managed<gPanthera::ContentTabBar>(new_stack, Gtk::Orientation::HORIZONTAL, dynamic_cast<gPanthera::ContentTabBar*>(widget->get_stack()->get_parent()->get_first_child())->get_extra_child_function());
211
auto new_notebook = Gtk::make_managed<gPanthera::ContentNotebook>(new_stack, new_switcher);
212
auto window = new gPanthera::ContentWindow(new_notebook);
213
widget->redock(new_stack);
214
window->present();
215
new_stack->signal_leave_empty.connect([window]() {
216
window->close();
217
delete window;
218
});
219
return true;
220
};
221
222
auto return_extra_child = [this](gPanthera::ContentTabBar *switcher) {
223
auto new_tab_button = Gtk::make_managed<Gtk::Button>();
224
new_tab_button->set_child(*Gtk::make_managed<Gtk::Image>(Gio::Icon::create("list-add-symbolic")));
225
new_tab_button->set_tooltip_text("New tab");
226
new_tab_button->signal_clicked().connect([this, switcher]() {
227
on_new_tab(switcher->get_stack());
228
});
229
return new_tab_button;
230
};
231
auto content_stack = Gtk::make_managed<gPanthera::ContentStack>(content_manager, detach_handler);
232
auto content_stack_switcher = Gtk::make_managed<gPanthera::ContentTabBar>(content_stack, Gtk::Orientation::HORIZONTAL, return_extra_child);
233
content_manager->add_stack(content_stack);
234
WebKitWebView *webview = WEBKIT_WEB_VIEW(webkit_web_view_new()); // for some reason, this has to be created
235
content->set_name("content_box");
236
auto content_notebook = Gtk::make_managed<gPanthera::ContentNotebook>(content_stack, content_stack_switcher, Gtk::PositionType::TOP);
237
content->append(*content_notebook);
238
inner_paned->set_start_child(*content);
239
inner_paned->set_end_child(*dock_stack_1);
240
outer_paned->set_end_child(*inner_paned);
241
outer_grid->attach(*outer_paned, 1, 1, 1, 1);
242
243
// Get search engines
244
std::ifstream search_engines_file_in("search_engines.json");
245
if(search_engines_file_in) {
246
std::string search_engines_json((std::istreambuf_iterator<char>(search_engines_file_in)), std::istreambuf_iterator<char>());
247
search_engines_file_in.close();
248
set_search_engines_from_json(search_engines_json);
249
} else {
250
search_engines_file_in.close();
251
auto empty_json = nlohmann::json::array();
252
std::ofstream search_engines_file_out("search_engines.json");
253
search_engines_file_out << empty_json.dump(4);
254
}
255
256
// Create the toolbar
257
auto main_toolbar = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL, 8);
258
// URL bar
259
url_bar = Gtk::make_managed<Gtk::Entry>();
260
url_bar->set_placeholder_text("Enter URL");
261
url_bar->set_hexpand(true);
262
auto load_url_callback = [this]() {
263
auto page = content_manager->get_last_operated_page();
264
if(page) {
265
if(auto webview = WEBKIT_WEB_VIEW(page->get_child()->get_first_child()->gobj())) {
266
webkit_web_view_load_uri(webview, url_bar->get_text().c_str());
267
}
268
}
269
};
270
// Go
271
auto go_button = Gtk::make_managed<Gtk::Button>("Go");
272
go_button->signal_clicked().connect(load_url_callback);
273
url_bar->signal_activate().connect(load_url_callback);
274
content_manager->signal_page_operated.connect([this](gPanthera::ContentPage *page) {
275
if(!page->get_child()) {
276
return;
277
}
278
if(!page->get_child()->get_first_child()) {
279
return;
280
}
281
url_bar->set_text(webkit_web_view_get_uri(WEBKIT_WEB_VIEW(page->get_child()->get_first_child()->gobj())));
282
guint url_update_handler = g_signal_connect(page->get_child()->get_first_child()->gobj(), "notify", G_CALLBACK(notify_focused_callback), this);
283
std::shared_ptr<sigc::connection> control_signal_handler = std::make_shared<sigc::connection>();
284
*control_signal_handler = page->signal_control_status_changed.connect([this, page, control_signal_handler, url_update_handler](bool controlled) {
285
if(!controlled) {
286
control_signal_handler->disconnect();
287
if(page->get_child() && page->get_child()->get_first_child() && WEBKIT_IS_WEB_VIEW(page->get_child()->get_first_child()->gobj())) {
288
g_signal_handler_disconnect(page->get_child()->get_first_child()->gobj(), url_update_handler);
289
}
290
}
291
});
292
});
293
// Back, forward, reload
294
auto back_button = Gtk::make_managed<Gtk::Button>();
295
back_button->set_child(*Gtk::make_managed<Gtk::Image>(Gio::Icon::create("go-previous-symbolic")));
296
back_button->set_tooltip_text("Back");
297
auto forward_button = Gtk::make_managed<Gtk::Button>();
298
forward_button->set_child(*Gtk::make_managed<Gtk::Image>(Gio::Icon::create("go-next-symbolic")));
299
forward_button->set_tooltip_text("Forward");
300
auto reload_button = Gtk::make_managed<Gtk::Button>();
301
reload_button->set_child(*Gtk::make_managed<Gtk::Image>(Gio::Icon::create("view-refresh-symbolic")));
302
reload_button->set_tooltip_text("Reload");
303
back_button->signal_clicked().connect([this]() {
304
auto page = content_manager->get_last_operated_page();
305
if(page) {
306
if(auto webview = WEBKIT_WEB_VIEW(page->get_child()->get_first_child()->gobj())) {
307
webkit_web_view_go_back(webview);
308
}
309
}
310
});
311
forward_button->signal_clicked().connect([this]() {
312
auto page = content_manager->get_last_operated_page();
313
if(page) {
314
if(auto webview = WEBKIT_WEB_VIEW(page->get_child()->get_first_child()->gobj())) {
315
webkit_web_view_go_forward(webview);
316
}
317
}
318
});
319
reload_button->signal_clicked().connect([this]() {
320
auto page = content_manager->get_last_operated_page();
321
if(page) {
322
if(auto webview = WEBKIT_WEB_VIEW(page->get_child()->get_first_child()->gobj())) {
323
webkit_web_view_reload(webview);
324
}
325
}
326
});
327
// Search bar
328
// TODO: provide history, provide a menu button with the other engines
329
auto search_bar = Gtk::make_managed<Gtk::Entry>();
330
search_bar->set_placeholder_text("Search");
331
search_bar->set_hexpand(true);
332
if(search_engines.empty()) {
333
search_bar->set_sensitive(false);
334
search_bar->set_placeholder_text("No search");
335
}
336
auto search_callback = [this, search_bar, content_stack]() {
337
// Create a new tab with the search results
338
if(content_manager->get_last_operated_page()) {
339
on_new_tab(nullptr);
340
} else {
341
on_new_tab(content_stack);
342
}
343
auto page = content_manager->get_last_operated_page();
344
if(page) {
345
if(auto webview = WEBKIT_WEB_VIEW(page->get_child()->get_first_child()->gobj())) {
346
auto search_url = default_search_engine->get_search_url(search_bar->get_text());
347
webkit_web_view_load_uri(webview, search_url.c_str());
348
}
349
}
350
};
351
if(default_search_engine) {
352
search_bar->signal_activate().connect(search_callback);
353
}
354
// Assemble the toolbar
355
main_toolbar->append(*back_button);
356
main_toolbar->append(*forward_button);
357
main_toolbar->append(*reload_button);
358
main_toolbar->append(*url_bar);
359
main_toolbar->append(*go_button);
360
main_toolbar->append(*search_bar);
361
if(default_search_engine) {
362
auto search_button = Gtk::make_managed<Gtk::Button>(default_search_engine->name);
363
search_button->signal_clicked().connect(search_callback);
364
main_toolbar->append(*search_button);
365
}
366
outer_grid->attach(*main_toolbar, 0, 0, 2, 1);
367
window->set_child(*outer_grid);
368
debug_button->signal_clicked().connect([this]() {
369
if(content_manager->get_last_operated_page()) {
370
std::cout << "Last operated page: " << content_manager->get_last_operated_page()->get_name() << std::endl;
371
} else {
372
std::cout << "No page operated!" << std::endl;
373
}
374
});
375
// TODO: Use the last operated page and allow opening tabs next to the last operated page using certain panes
376
// Load the existing layout, if it exists
377
std::ifstream layout_file_in("layout.json");
378
if(layout_file_in) {
379
std::string layout_json((std::istreambuf_iterator<char>(layout_file_in)), std::istreambuf_iterator<char>());
380
layout_file_in.close();
381
layout_manager->restore_json_layout(layout_json);
382
} else {
383
// Create a new layout if the file doesn't exist
384
layout_file_in.close();
385
386
dock_stack_1->add_pane(*pane_1);
387
dock_stack_1->add_pane(*pane_3);
388
dock_stack_2->add_pane(*pane_2);
389
390
std::ofstream layout_file_out("layout.json");
391
layout_file_out << layout_manager->get_layout_as_json();
392
layout_file_out.close();
393
}
394
// Save the layout when changed
395
layout_manager->signal_pane_moved.connect([this](gPanthera::DockablePane *pane) {
396
std::ofstream layout_file_out("layout.json");
397
layout_file_out << layout_manager->get_layout_as_json();
398
layout_file_out.close();
399
std::cout << "Layout changed: " << layout_manager->get_layout_as_json() << std::endl;
400
});
401
402
auto new_tab_action = Gio::SimpleAction::create("new_tab");
403
new_tab_action->signal_activate().connect([this](const Glib::VariantBase&) {
404
on_new_tab(nullptr);
405
});
406
add_action(new_tab_action);
407
set_accels_for_action("app.new_tab", {"<Primary>T"});
408
auto close_tab_action = Gio::SimpleAction::create("close_tab");
409
close_tab_action->signal_activate().connect([this](const Glib::VariantBase&) {
410
auto page = content_manager->get_last_operated_page();
411
if(page) {
412
page->close();
413
}
414
});
415
add_action(close_tab_action);
416
set_accels_for_action("app.close_tab", {"<Primary>W"});
417
418
// Load plugins
419
std::ifstream plugin_file_in("plugins.json");
420
if(plugin_file_in) {
421
std::string plugin_json((std::istreambuf_iterator<char>(plugin_file_in)), std::istreambuf_iterator<char>());
422
plugin_file_in.close();
423
auto json = nlohmann::json::parse(plugin_json);
424
for(auto &plugin : json) {
425
auto plugin_path = plugin["path"].get<std::string>();
426
load_plugin(plugin_path);
427
}
428
} else {
429
plugin_file_in.close();
430
auto empty_json = nlohmann::json::array();
431
std::ofstream plugin_file_out("plugins.json");
432
plugin_file_out << empty_json.dump(4);
433
plugin_file_out.close();
434
}
435
}
436
437
void on_activate() override {
438
window->present();
439
}
440
441
void set_search_engines_from_json(const std::string &json_string) {
442
auto json = nlohmann::json::parse(json_string);
443
Glib::ustring default_search_engine_name;
444
for(auto &engine : json) {
445
SearchEngine search_engine;
446
search_engine.name = engine["name"].get<std::string>();
447
search_engine.url = engine["url"].get<std::string>();
448
search_engines.push_back(search_engine);
449
if(engine.contains("default") && engine["default"].get<bool>()) {
450
default_search_engine_name = engine["name"].get<std::string>();
451
}
452
}
453
for(auto &search_engine : search_engines) {
454
if(search_engine.name == default_search_engine_name) {
455
default_search_engine = &search_engine;
456
break;
457
}
458
}
459
}
460
public:
461
static Glib::RefPtr<PantheraWww> create() {
462
return Glib::make_refptr_for_instance<PantheraWww>(new PantheraWww());
463
}
464
465
std::shared_ptr<gPanthera::LayoutManager> get_layout_manager() {
466
return layout_manager;
467
}
468
469
std::shared_ptr<gPanthera::ContentManager> get_content_manager() {
470
return content_manager;
471
}
472
473
void load_plugin(const std::string &plugin_path) {
474
void *handle = dlopen(plugin_path.c_str(), RTLD_LAZY | RTLD_GLOBAL);
475
if(!handle) {
476
std::cerr << "Failed to load plugin: " << dlerror() << std::endl;
477
return;
478
}
479
auto entrypoint = (plugin_entrypoint_type)dlsym(handle, "plugin_init");
480
if(!entrypoint) {
481
std::cerr << "Failed to find entrypoint in plugin: " << dlerror() << std::endl;
482
dlclose(handle);
483
return;
484
}
485
entrypoint();
486
}
487
};
488
489
Glib::RefPtr<PantheraWww> app = nullptr;
490
491
extern "C" {
492
void panthera_log(const char *message) {
493
std::cerr << message << std::endl;
494
}
495
496
void panthera_add_pane(const char *id, const char *label, GtkImage *icon, GtkWidget *pane) {
497
auto pane_child = Glib::wrap(pane);
498
auto icon_cc = Glib::wrap(icon);
499
auto label_cc = Glib::ustring(label);
500
auto id_cc = Glib::ustring(id);
501
auto new_pane = Gtk::make_managed<gPanthera::DockablePane>(app->get_layout_manager(), *pane_child, id_cc, label_cc, icon_cc);
502
app->get_layout_manager()->add_pane(new_pane);
503
}
504
}
505
506
int main(int argc, char *argv[]) {
507
gPanthera::init();
508
app = PantheraWww::create();
509
return app->run(argc, argv);
510
}