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