|
|
b83518 |
--- evince-3.21.92/browser-plugin/EvBrowserPluginMain.cpp
|
|
|
b83518 |
+++ evince-3.21.92/browser-plugin/EvBrowserPluginMain.cpp
|
|
|
b83518 |
@@ -38,11 +38,40 @@ static EvBrowserPlugin *pluginForInstanc
|
|
|
b83518 |
return static_cast<EvBrowserPlugin *>(instance->pdata);
|
|
|
b83518 |
}
|
|
|
b83518 |
|
|
|
b83518 |
+static gboolean gtkToolkitIsCompatible(NPP instance)
|
|
|
b83518 |
+{
|
|
|
b83518 |
+ NPNToolkitType toolkit_type = NPNVGtk12;
|
|
|
b83518 |
+ NPError error;
|
|
|
b83518 |
+
|
|
|
b83518 |
+ error = browser->getvalue(instance, NPNVToolkit, &toolkit_type);
|
|
|
b83518 |
+
|
|
|
b83518 |
+ if (error == NPERR_NO_ERROR &&
|
|
|
b83518 |
+ (toolkit_type == NPNVGtk12 ||
|
|
|
b83518 |
+ toolkit_type == NPNVGtk2))
|
|
|
b83518 |
+ return FALSE;
|
|
|
b83518 |
+ else
|
|
|
b83518 |
+ return TRUE;
|
|
|
b83518 |
+}
|
|
|
b83518 |
+
|
|
|
b83518 |
NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char *argn[], char *argv[], NPSavedData *savedData)
|
|
|
b83518 |
{
|
|
|
b83518 |
if (!instance)
|
|
|
b83518 |
return NPERR_INVALID_INSTANCE_ERROR;
|
|
|
b83518 |
|
|
|
b83518 |
+ if (!gtkToolkitIsCompatible(instance))
|
|
|
b83518 |
+ return NPERR_GENERIC_ERROR;
|
|
|
b83518 |
+
|
|
|
b83518 |
+ GBytes *resourceData = g_resources_lookup_data("/org/gnome/evince/browser/ui/evince-browser.css", G_RESOURCE_LOOKUP_FLAGS_NONE, nullptr);
|
|
|
b83518 |
+ if (resourceData) {
|
|
|
b83518 |
+ GtkCssProvider *cssProvider = gtk_css_provider_new();
|
|
|
b83518 |
+
|
|
|
b83518 |
+ gtk_css_provider_load_from_data(cssProvider, static_cast<const gchar *>(g_bytes_get_data(resourceData, nullptr)), g_bytes_get_size(resourceData), nullptr);
|
|
|
b83518 |
+ g_bytes_unref(resourceData);
|
|
|
b83518 |
+
|
|
|
b83518 |
+ gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(cssProvider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
|
|
b83518 |
+ g_object_unref(cssProvider);
|
|
|
b83518 |
+ }
|
|
|
b83518 |
+
|
|
|
b83518 |
return EvBrowserPlugin::create(instance)->initialize(pluginType, mode, argc, argn, argv, savedData);
|
|
|
b83518 |
}
|
|
|
b83518 |
|
|
|
b83518 |
@@ -197,6 +226,11 @@ NPError NP_Initialize(NPNetscapeFuncs *b
|
|
|
b83518 |
if ((browserFuncs->version >> 8) > NP_VERSION_MAJOR)
|
|
|
b83518 |
return NPERR_INCOMPATIBLE_VERSION_ERROR;
|
|
|
b83518 |
|
|
|
b83518 |
+ browser = browserFuncs;
|
|
|
b83518 |
+
|
|
|
b83518 |
+ if (!gtkToolkitIsCompatible(NULL))
|
|
|
b83518 |
+ return NPERR_GENERIC_ERROR;
|
|
|
b83518 |
+
|
|
|
b83518 |
if (!ev_init())
|
|
|
b83518 |
return NPERR_GENERIC_ERROR;
|
|
|
b83518 |
|
|
|
b83518 |
@@ -207,20 +241,8 @@ NPError NP_Initialize(NPNetscapeFuncs *b
|
|
|
b83518 |
return NPERR_GENERIC_ERROR;
|
|
|
b83518 |
#endif
|
|
|
b83518 |
|
|
|
b83518 |
- browser = browserFuncs;
|
|
|
b83518 |
initializePluginFuncs(pluginFuncs);
|
|
|
b83518 |
|
|
|
b83518 |
- GBytes *resourceData = g_resources_lookup_data("/org/gnome/evince/browser/ui/evince-browser.css", G_RESOURCE_LOOKUP_FLAGS_NONE, nullptr);
|
|
|
b83518 |
- if (resourceData) {
|
|
|
b83518 |
- GtkCssProvider *cssProvider = gtk_css_provider_new();
|
|
|
b83518 |
-
|
|
|
b83518 |
- gtk_css_provider_load_from_data(cssProvider, static_cast<const gchar *>(g_bytes_get_data(resourceData, nullptr)), g_bytes_get_size(resourceData), nullptr);
|
|
|
b83518 |
- g_bytes_unref(resourceData);
|
|
|
b83518 |
-
|
|
|
b83518 |
- gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(cssProvider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
|
|
b83518 |
- g_object_unref(cssProvider);
|
|
|
b83518 |
- }
|
|
|
b83518 |
-
|
|
|
b83518 |
return NPERR_NO_ERROR;
|
|
|
b83518 |
}
|
|
|
b83518 |
|