|
| 1 | +See this topic on the CEF C++ forum for more details: |
| 2 | +http://www.magpcss.org/ceforum/viewtopic.php?f=6&t=10641 |
| 3 | + |
| 4 | +Do the following changes in the CEF C++ sources: |
| 5 | + |
| 6 | +1. In `chromium/src/cef/libcef/browser/browser_host_impl_gtk.cc`: |
| 7 | + |
| 8 | + At the end of the CefBrowserImpl::UIT_CreateBrowser() function, |
| 9 | + before the return statement add the following code: |
| 10 | + |
| 11 | + gtk_widget_show_all(GTK_WIDGET(window_info_.widget)); |
| 12 | + |
| 13 | +2. In `chromium/src/cef/libcef/webwidget_host_gtk.cc`: |
| 14 | + |
| 15 | + In WebWidgetHostGtkWidget::CreateNewWidget() function replace this line: |
| 16 | + |
| 17 | + gtk_box_pack_start(GTK_BOX(parent_view), widget, TRUE, TRUE, 0); |
| 18 | + |
| 19 | + With the following code: |
| 20 | + |
| 21 | + if (GTK_IS_BOX(parent_view)) { |
| 22 | + gtk_box_pack_start(GTK_BOX(parent_view), widget, TRUE, TRUE, 0); |
| 23 | + } else { |
| 24 | + // Parent view shouldn't contain any children, but in wxWidgets library |
| 25 | + // there will be GtkPizza widget for Panel or any other control. |
| 26 | + GList *children, *iter; |
| 27 | + children = gtk_container_get_children(GTK_CONTAINER(parent_view)); |
| 28 | + GtkWidget* child = NULL; |
| 29 | + GtkWidget* vbox = gtk_vbox_new(FALSE, 0); |
| 30 | + for (iter = children; iter != NULL; iter = g_list_next(iter)) { |
| 31 | + child = GTK_WIDGET(iter->data); |
| 32 | + // We will have to keep a reference to that child that we remove, |
| 33 | + // otherwise we will get lots of warnings like "invalid unclassed |
| 34 | + // pointer in cast to `GtkPizza'". First we increase a reference, |
| 35 | + // we need to do this for a moment before we add this child to the |
| 36 | + // vbox, then we will decrease that reference. |
| 37 | + g_object_ref(G_OBJECT(child)); |
| 38 | + gtk_container_remove(GTK_CONTAINER(parent_view), child); |
| 39 | + } |
| 40 | + g_list_free(children); |
| 41 | + gtk_box_pack_start(GTK_BOX(vbox), widget, TRUE, TRUE, 0); |
| 42 | + if (child != NULL) { |
| 43 | + // This child is packed to the box only so that its reference lives, |
| 44 | + // as it might be referenced from other code thus resulting in errors. |
| 45 | + gtk_box_pack_end(GTK_BOX(vbox), child, FALSE, FALSE, 0); |
| 46 | + gtk_widget_hide(GTK_WIDGET(child)); |
| 47 | + g_object_unref(G_OBJECT(child)); |
| 48 | + } |
| 49 | + gtk_widget_show(GTK_WIDGET(vbox)); |
| 50 | + if (GTK_IS_SCROLLED_WINDOW(parent_view)) |
| 51 | + gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(parent_view), vbox); |
| 52 | + else |
| 53 | + gtk_container_add(GTK_CONTAINER(parent_view), vbox); |
| 54 | + } |
0 commit comments