From 676b1ed679778c04832ac096a8d2a9d35970c183 Mon Sep 17 00:00:00 2001 From: "hoa.nguyen%intel.com" Date: Tue, 31 Aug 1999 00:12:15 +0000 Subject: [PATCH] Extended the example to create a simple button with label. git-svn-id: svn://10.0.0.236/trunk@45226 18797224-902f-48f8-a5cc-f745e15eee43 --- .../plugin/samples/simple/npsimple.cpp | 19 ++++++++++++++++++- mozilla/modules/plugin/test/npsimple.cpp | 19 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/mozilla/modules/plugin/samples/simple/npsimple.cpp b/mozilla/modules/plugin/samples/simple/npsimple.cpp index b6242338134..9bb4b04c8c5 100644 --- a/mozilla/modules/plugin/samples/simple/npsimple.cpp +++ b/mozilla/modules/plugin/samples/simple/npsimple.cpp @@ -41,6 +41,9 @@ #include "nsISupports.h" #include "nsIFactory.h" #include "simpleCID.h" +#include +#include +#include /*------------------------------------------------------------------------------ * Windows Includes @@ -91,6 +94,7 @@ typedef struct _PlatformInstance typedef struct _PlatformInstance { Window window; + GtkWidget *widget; Display * display; uint32 x, y; uint32 width, height; @@ -1049,7 +1053,8 @@ SimplePluginInstance::PlatformNew(void) nsresult SimplePluginInstance::PlatformDestroy(void) { - return NS_OK; + gtk_widget_destroy(fPlatform.widget); + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -1061,6 +1066,18 @@ SimplePluginInstance::PlatformDestroy(void) nsresult SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window) { + if (window == NULL || window->window == NULL) + return NS_ERROR_NULL_POINTER; + + fPlatform.widget = (GtkWidget *)window->window; + GtkWidget *button; + + button = gtk_button_new_with_label("Hello World"); + gtk_layout_put(GTK_LAYOUT(fPlatform.widget), button, 0, 0); + + gtk_widget_show(button); + gtk_widget_show(fPlatform.widget); + return NS_OK; } diff --git a/mozilla/modules/plugin/test/npsimple.cpp b/mozilla/modules/plugin/test/npsimple.cpp index b6242338134..9bb4b04c8c5 100644 --- a/mozilla/modules/plugin/test/npsimple.cpp +++ b/mozilla/modules/plugin/test/npsimple.cpp @@ -41,6 +41,9 @@ #include "nsISupports.h" #include "nsIFactory.h" #include "simpleCID.h" +#include +#include +#include /*------------------------------------------------------------------------------ * Windows Includes @@ -91,6 +94,7 @@ typedef struct _PlatformInstance typedef struct _PlatformInstance { Window window; + GtkWidget *widget; Display * display; uint32 x, y; uint32 width, height; @@ -1049,7 +1053,8 @@ SimplePluginInstance::PlatformNew(void) nsresult SimplePluginInstance::PlatformDestroy(void) { - return NS_OK; + gtk_widget_destroy(fPlatform.widget); + return NS_OK; } /*+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -1061,6 +1066,18 @@ SimplePluginInstance::PlatformDestroy(void) nsresult SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window) { + if (window == NULL || window->window == NULL) + return NS_ERROR_NULL_POINTER; + + fPlatform.widget = (GtkWidget *)window->window; + GtkWidget *button; + + button = gtk_button_new_with_label("Hello World"); + gtk_layout_put(GTK_LAYOUT(fPlatform.widget), button, 0, 0); + + gtk_widget_show(button); + gtk_widget_show(fPlatform.widget); + return NS_OK; }