Created
March 2, 2023 14:49
-
-
Save aperezdc/f6a65a95f2baa222c0ce9d65e516e13b to your computer and use it in GitHub Desktop.
Minimal WPE launcher using libcogcore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* SPDX-License-Identifier: MIT | |
* | |
* cc -o minicog minicog.c $(pkg-config wpe-webkit-1.1 cogcore --cflags --libs) | |
*/ | |
#include <cog/cog.h> | |
static const char *s_starturl = NULL; | |
static WebKitWebView* | |
on_create_view(CogShell *shell, CogPlatform *platform) | |
{ | |
g_autoptr(GError) error = NULL; | |
WebKitWebViewBackend *view_backend = cog_platform_get_view_backend(platform, NULL, &error); | |
if (!view_backend) | |
g_error("Cannot obtain view backend: %s", error->message); | |
g_autoptr(WebKitWebView) web_view = | |
g_object_new(WEBKIT_TYPE_WEB_VIEW, | |
"settings", cog_shell_get_web_settings(shell), | |
"web-context", cog_shell_get_web_context(shell), | |
"backend", view_backend, | |
NULL); | |
cog_platform_init_web_view(platform, web_view); | |
webkit_web_view_load_uri(web_view, s_starturl); | |
return g_steal_pointer(&web_view); | |
} | |
int | |
main(int argc, char *argv[]) | |
{ | |
g_set_application_name("minicog"); | |
if (argc != 2 && argc != 3) { | |
g_printerr("Usage: %s [URL [platform]]\n", argv[0]); | |
return EXIT_FAILURE; | |
} | |
g_autoptr(GError) error = NULL; | |
if (!(s_starturl = cog_uri_guess_from_user_input(argv[1], TRUE, &error))) | |
g_error("Invalid URL '%s': %s", argv[1], error->message); | |
cog_modules_add_directory(COG_MODULEDIR); | |
g_autoptr(GApplication) app = g_application_new(NULL, G_APPLICATION_DEFAULT_FLAGS); | |
g_autoptr(CogShell) shell = cog_shell_new("minicog", FALSE); | |
g_autoptr(CogPlatform) platform = | |
cog_platform_new((argc == 3) ? argv[2] : g_getenv("COG_PLATFORM"), &error); | |
if (!platform) | |
g_error("Cannot create platform: %s", error->message); | |
if (!cog_platform_setup(platform, shell, "", &error)) | |
g_error("Cannot setup platform: %s\n", error->message); | |
g_signal_connect(shell, "create-view", G_CALLBACK(on_create_view), platform); | |
g_signal_connect_swapped(app, "shutdown", G_CALLBACK(cog_shell_shutdown), shell); | |
g_signal_connect_swapped(app, "startup", G_CALLBACK(cog_shell_startup), shell); | |
g_signal_connect(app, "activate", G_CALLBACK(g_application_hold), NULL); | |
return g_application_run(app, 1, argv); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for replying.
I do, indeed, pass
drm
after-P
. Typing too fast here.I finally have time to look back at this; first off, there are a few things that seem to have disappeared in the version of libcogcore (12.0.0, cog version 0.19.1) i'm using.
The following are undefined:
cog_shell_shutdown
cog_shell_startup
cog_platform_new
So i commented out the two lines with
g_signal_connect_swapped
and replaced the call tocog_platform_new
with:Now, running :
G_MESSAGES_DEBUG='Cog-Core Cog-DRM' ./app index.html drm
gives :
Commenting out the line that connect the signal for
create-view
doesn't fix it; it only make the critical message disappear.