how to draw gtk widget(like buttons) in the firefox npapi plugin under linux?
"spark.bao" <[email protected]> Fri, 15 Nov 2013 18:14:59 -0800 (PST)
| Newsgroups | gmane.comp.mozilla.devel.plugins |
|---|---|
| Message-ID | <[email protected]> |
Hello everybody,
I has known how to write a simple npapi plugin. But now I am in troubles to draw some buttons in the plugin.
I download a simple sample named webp-npapi (http://code.google.com/p/webp-npapi-linux/) and modify it, it now can work well in my firefox.
I also download a complex sample named npapi-vlc (http://git.videolan.org/?p=npapi-vlc.git;a=summary) and has read it.
I want to draw some buttons in my own plugin, so I imitate the codes of npapi-vlc to modify webp-npapi. I change the type of webp-npapi from windowless to window by comment the following codes in constructor of CPlugin class:
(http://code.google.com/p/webp-npapi-linux/source/browse/trunk/CPlugin.cpp)
/*
// Make sure we can render this plugin
NPBool browserSupportsWindowless = false;
s_pBrowserFunctions->getvalue(instance, NPNVSupportsWindowless, &browserSupportsWindowless);
if( !browserSupportsWindowless )
throw std::runtime_error("Windowless mode not supported by the browser");
s_pBrowserFunctions->setvalue(instance, NPPVpluginWindowBool, (void*) false);
*/
then I start draw a button in CPlugin::setWindow() function:
NPError CPlugin::setWindow(const NPWindow * const window)
{
#ifdef WEBPNPAPI_DEBUG
printf("CPlugin::setWindow() - Window set\n");
#endif
m_window = *window;
//I add these codes to draw a button
printf("test start\n");
GdkColor color_bg;
gdk_color_parse("#AAAAAA", &color_bg);
Window socket = (Window)m_window.window;
GtkWidget *parent = gtk_plug_new(socket);
gtk_widget_modify_bg(parent, GTK_STATE_NORMAL, &color_bg);
GtkWidget *button = gtk_button_new_with_label("hello");
gtk_container_add(GTK_CONTAINER(parent), button);
gtk_widget_show_all(parent);
printf("test end\n");
GtkRequisition req;
req.width = m_window.width;
req.height = m_window.height;
gtk_widget_size_request(parent, &req);
return NPERR_NO_ERROR;
}
But, It doesn't show anything in the webpage...
So I really want to know what is the most important things you must notice when you want to draw some gtk widget in your plugin?
thx!
_______________________________________________
dev-tech-plugins mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-plugins