Blame SOURCES/evince-3.21.4-NPNVToolKit.patch

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