A mozilla gtk plugin sample
Mozilla October 31st, 2006
前段时间把 gtk 的 plugin 搞定了, 下一步就得把 scintilla 集成进来了.
这里保存一个简单的 gtk plugin 例子以便以后查阅.
这个 plugin 实现的功能很简单, 就是把 gtk 的 tutorial 里的第二个例子给实现了.
单击 “Hello World” Button 调用 gprintf 在终端显示 Hello World.
这个例子里, widget 有了, event handle 也有了. 麻雀虽小, 五脏俱全地说.
plugin.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #ifndef __PLUGIN_H__ #define __PLUGIN_H__ /* Xlib/Xt stuff */ #include <x11 /Xlib.h> #include </x11><x11 /Intrinsic.h> #include </x11><x11 /cursorfont.h> #include <gtk /gtk.h> #include "pluginbase.h" class nsPluginInstance : public nsPluginInstanceBase { public: nsPluginInstance(NPP aInstance); virtual ~nsPluginInstance(); NPBool init(NPWindow* aWindow); void shut(); NPBool isInitialized() { return mInitialized; } NPError GetValue(NPPVariable variable, void *value); NPError SetWindow(NPWindow* aWindow); // locals const char * getVersion(); private: NPP mInstance; NPBool mInitialized; GtkWidget* m_GtkWidget; GtkWidget *button; Window mWindow; int mX, mY; int mWidth, mHeight; }; #endif // __PLUGIN_H__ </gtk></x11> |