diff --git a/mozilla/modules/plugin/default/unix/Makefile.in b/mozilla/modules/plugin/default/unix/Makefile.in index cfa521e05ae..470e6d86bfd 100644 --- a/mozilla/modules/plugin/default/unix/Makefile.in +++ b/mozilla/modules/plugin/default/unix/Makefile.in @@ -48,7 +48,7 @@ DEFINES += -D_IMPL_NS_PLUGIN include $(topsrcdir)/config/rules.mk -EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) -lXt -lXpm \ +EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) \ $(NULL) ifndef MOZ_MONOLITHIC_TOOLKIT diff --git a/mozilla/modules/plugin/default/unix/npshell.c b/mozilla/modules/plugin/default/unix/npshell.c index 19b0fb5bda3..0be4e6bd3e8 100644 --- a/mozilla/modules/plugin/default/unix/npshell.c +++ b/mozilla/modules/plugin/default/unix/npshell.c @@ -152,6 +152,7 @@ NPP_New(NPMIMEType pluginType, return NPERR_NO_ERROR; } + NPError NPP_Destroy(NPP instance, NPSavedData** save) { @@ -164,8 +165,6 @@ NPP_Destroy(NPP instance, NPSavedData** save) This = (PluginInstance*) instance->pdata; if (This != NULL) { - if (This->dialogBox) - destroyWidget(This); if (This->type) NPN_MemFree(This->type); if (This->pluginsPageUrl) @@ -222,8 +221,10 @@ NPP_SetWindow(NPP instance, NPWindow* window) This->visual = ws_info->visual; This->depth = ws_info->depth; This->colormap = ws_info->colormap; - makePixmap(This); - makeWidget(This); + if (This->exists != TRUE) { + This->exists = FALSE; + makeWidget(This); + } } return NPERR_NO_ERROR; } diff --git a/mozilla/modules/plugin/default/unix/nullplugin.c b/mozilla/modules/plugin/default/unix/nullplugin.c index 3d3c8ffc776..6fb2c2cd7d9 100644 --- a/mozilla/modules/plugin/default/unix/nullplugin.c +++ b/mozilla/modules/plugin/default/unix/nullplugin.c @@ -34,13 +34,6 @@ #include #include - -/* Xlib/Xt stuff */ -#include -#include -#include -#include - #include "npapi.h" #include "nullplugin.h" @@ -49,14 +42,32 @@ /* Global data */ static MimeTypeElement *head = NULL; -/* destroy the dialog box */ -void -destroyWidget(PluginInstance *This) +/* this function is used to clear the mime type cache list + whenever the dialog box is closed. We need to clear the + list in order to have the dialog box pop up again when + the page is reload. (it's because there is no puzzle + icon in unix to let the people actively forward to netscape + page) */ +static void +clearList(MimeTypeElement **typelist) { - if (This && This->dialogBox) - { - gtk_widget_destroy (GTK_WIDGET(This->dialogBox)); + MimeTypeElement *ele; + MimeTypeElement *ele2; + + if (typelist == NULL) + return; + + /* follow the head to free the list */ + ele = *typelist; + while (ele != NULL) { + ele2 = ele->next; + if (ele->value != NULL) + NPN_MemFree(ele->value); + NPN_MemFree(ele); + ele = ele2; } + *typelist = ele; + return; } /* callback function for the OK button */ @@ -88,7 +99,7 @@ DialogOKClicked (GtkButton *button, gpointer data) { /* If necessary, get the default plug-ins page resource */ char* address = This->pluginsPageUrl; - if (address == NULL || *address == 0) + if (address == NULL) { address = PLUGINSPAGE_URL; } @@ -109,14 +120,16 @@ DialogOKClicked (GtkButton *button, gpointer data) NPN_MemFree(url); } } - destroyWidget(This); + gtk_widget_destroy (dialogWindow); + clearList(&head); } /* the call back function for cancel button */ static void DialogCancelClicked (GtkButton *button, gpointer data) { - destroyWidget((PluginInstance*) data); + gtk_widget_destroy (GTK_WIDGET(data)); + clearList(&head); } /* a handy procedure to add a widget and pack it as well */ @@ -134,21 +147,23 @@ AddWidget (GtkWidget *widget, GtkWidget *packingbox) static gboolean isEqual(NPMIMEType t1, NPMIMEType t2) { - return (t1 && t2) ? (strcmp(t1, t2) == 0) : FALSE; + return(strcmp(t1, t2) == 0); } -static MimeTypeElement * +static gboolean isExist(MimeTypeElement **typelist, NPMIMEType type) { MimeTypeElement *ele; + if (typelist == NULL) return FALSE; + ele = *typelist; while (ele != NULL) { - if (isEqual(ele->pinst->type, type)) - return ele; + if (isEqual(ele->value, type)) + return TRUE; ele = ele->next; } - return NULL; + return FALSE; } NPMIMEType @@ -161,58 +176,19 @@ dupMimeType(NPMIMEType type) } static gboolean -addToList(MimeTypeElement **typelist, PluginInstance *This) +addToList(MimeTypeElement **typelist, NPMIMEType type) { - if (This && This->type && !isExist(typelist, This->type)) - { - MimeTypeElement *ele; - if ((ele = (MimeTypeElement *) NPN_MemAlloc(sizeof(MimeTypeElement)))) - { - ele->pinst = This; - ele->next = *typelist; - *typelist = ele; - return(TRUE); - } - } - return(FALSE); -} + MimeTypeElement *ele; -static gboolean -delFromList(MimeTypeElement **typelist, PluginInstance *This) -{ - if (typelist && This) - { - MimeTypeElement *ele_prev; - MimeTypeElement *ele = *typelist; - while (ele) - { - if (isEqual(ele->pinst->type, This->type)) - { - if (*typelist == ele) - { - *typelist = ele->next; - } else { - ele_prev->next = ele->next; - } - NPN_MemFree(ele); - return(TRUE); - } - ele_prev = ele; - ele = ele->next; - } - } - return(FALSE); -} + if (!typelist) return(FALSE); -static void -onDestroyWidget(GtkWidget *w, gpointer data) -{ - PluginInstance* This = (PluginInstance*) data; - if (This && This->dialogBox && This->dialogBox == w) - { - This->dialogBox = 0; - delFromList(&head, This); - } + if (isExist(typelist, type)) return(FALSE); + + ele = (MimeTypeElement *) NPN_MemAlloc(sizeof(MimeTypeElement)); + ele->value = dupMimeType(type); + ele->next = *typelist; + *typelist = ele; + return(TRUE); } /* create and display the dialog box */ @@ -224,37 +200,17 @@ makeWidget(PluginInstance *This) GtkWidget *okButton; GtkWidget *cancelButton; char message[1024]; - MimeTypeElement *ele; if (!This) return; - - /* need to check whether we already pop up a dialog box for previous - minetype in the same web page. It's require otherwise there will - be 2 dialog boxes pop if there are 2 plugin in the same web page - */ - if ((ele = isExist(&head, This->type))) - { - if (ele->pinst && ele->pinst->dialogBox) - { - GtkWidget *top_window = gtk_widget_get_toplevel(ele->pinst->dialogBox); - if (top_window && GTK_WIDGET_VISIBLE(top_window)) - { /* this will raise the toplevel window */ - gdk_window_show(top_window->window); - } - } - return; - } + if (This->exists == TRUE) return; dialogWindow = gtk_dialog_new(); This->dialogBox = dialogWindow; This->exists = TRUE; - This->dialogBox = dialogWindow; - addToList(&head, This); gtk_window_set_title(GTK_WINDOW(dialogWindow), PLUGIN_NAME); - gtk_window_set_position(GTK_WINDOW(dialogWindow), GTK_WIN_POS_CENTER); - gtk_window_set_modal(GTK_WINDOW(dialogWindow), FALSE); - gtk_container_set_border_width(GTK_CONTAINER(dialogWindow), 20); - gtk_window_set_policy(GTK_WINDOW(dialogWindow), FALSE, FALSE, TRUE); + /* gtk_window_set_position(GTK_WINDOW(dialogWindow), GTK_WIN_POS_CENTER); */ + gtk_window_set_modal(GTK_WINDOW(dialogWindow), TRUE); + gtk_container_set_border_width(GTK_CONTAINER(dialogWindow), 0); PR_snprintf(message, sizeof(message) - 1, MESSAGE, This->type); dialogMessage = AddWidget(gtk_label_new (message), @@ -271,145 +227,14 @@ makeWidget(PluginInstance *This) GTK_SIGNAL_FUNC(DialogOKClicked), This); gtk_signal_connect (GTK_OBJECT(cancelButton), "clicked", - GTK_SIGNAL_FUNC(DialogCancelClicked), This); + GTK_SIGNAL_FUNC(DialogCancelClicked), dialogWindow); - /* hookup to when the dialog is destroyed */ - gtk_signal_connect(GTK_OBJECT(dialogWindow), "destroy", - GTK_SIGNAL_FUNC(onDestroyWidget), This); - gtk_widget_show_all(dialogWindow); -} - -/* XPM */ -static char * npnul320_xpm[] = { -"32 32 6 1", -" c None", -". c #808080", -"+ c #F8F8F8", -"@ c #C0C0C0", -"# c #000000", -"$ c #00F8F8", -"........................++++++++", -".++++++++++++++++++++++..+++++++", -".+++++++++++++++++++++@.@.++++++", -".++@@@@@@@@@@@@@@@@@@@@.+@.+++++", -".++@@@@@@@@@.....@@@@@@.++@.++++", -".++@@@@@@@@.+++++#@@@@@.+++@.+++", -".++@@@@@@@.++$$$$$#@@@@.++++@.++", -".++@@@@@@@.+$$$$$$#.@@@.+++++@.+", -".++@@@...@@.+$$$$#..###.#######+", -".++@@.+++$$++$$$$$##++$#......#+", -".++@@.+$$$++$$$$$$$+$$$#......#+", -".++@@.+$$$$$$$$$$$$$$$$#..@@++#+", -".++@@@$$$$$$$$$$$$$$$$#...@@++#+", -".++@@@$#$##.$$$$$$##$$#...@@++#+", -".++@@@@##...$$$$$#..##...@@@++#+", -".++@@@@@....+$$$$#.......@@@++#+", -".++@@@@@@...+$$$$#.@@@..@@@@++#+", -".++@@@@..@@.+$$$$#.@##@@@@@@++#+", -".++@@@.++$$++$$$$$##$$#@@@@@++#+", -".++@@@.+$$++$$$$$$$$$$#@@@@@++#+", -".++@@.++$$$$$$$$$$$$$$$#@@@@++#+", -".++@@.+$$$$$$$$$$$$$$$$#.@@@++#+", -".++@@.+$$##$$$$$$$##$$$#..@@++#+", -".++@@@###...$$$$$#.@###...@@++#+", -".++@@@@....$$$$$$$#.@.....@@++#+", -".++@@@@@...$$$$$$$#..@...@@@++#+", -".++@@@@@@@@#$$$$$#...@@@@@@@++#+", -".++@@@@@@@@@#####...@@@@@@@@++#+", -".++@@@@@@@@@@......@@@@@@@@@++#+", -".+++++++++++++....++++++++++++#+", -".+++++++++++++++++++++++++++++#+", -"###############################+"}; - - -static Pixmap aPixmap = 0, aShapeMask = 0; -static XpmAttributes xpm_attr; -static Cursor cursor = 0; - -static int -createPixmap(PluginInstance *This) -{ - int err = 0; - if (aPixmap) return err; - - xpm_attr.valuemask = 0; - err = XpmCreatePixmapFromData(This->display, This->window, npnul320_xpm, &aPixmap, &aShapeMask, &xpm_attr); - if (err) { - fprintf(stderr, "%s\n", XpmGetErrorString(err)); - } - return err; -} - -static void -drawPixmap(PluginInstance *This) -{ - if (aPixmap) - { - int dest_x = This->width/2 - xpm_attr.width/2; - int dest_y = This->height/2 - xpm_attr.height/2; - if (dest_x >= 0 && dest_y >= 0) - { - GC gc; - gc = XCreateGC(This->display, This->window, 0, NULL); - XCopyArea(This->display, aPixmap, This->window, gc, - 0, 0, xpm_attr.width, xpm_attr.height, dest_x, dest_y); - XFreeGC(This->display, gc); - } - } -} - -static void -set_cursor (PluginInstance *This) -{ - if (!cursor) - { - cursor = XCreateFontCursor(This->display, XC_hand2); - } - if (cursor) - { - XDefineCursor(This->display, This->window, cursor); - } -} - -static void -xt_event_handler(Widget xt_w, PluginInstance *This, XEvent *xevent, Boolean *b) -{ - switch (xevent->type) - { - case Expose: - /* get rid of all other exposure events */ - while(XCheckTypedWindowEvent(This->display, This->window, Expose, xevent)); - drawPixmap(This); - break; - case ButtonRelease: - makeWidget(This); - break; - default: - break; - } -} - -static void -addXtEventHandler(PluginInstance *This) -{ - Display *dpy = (Display*) This->display; - Window xwin = (Window) This->window; - Widget xt_w = XtWindowToWidget(dpy, xwin); - if (xt_w) - { - long event_mask = ExposureMask | ButtonReleaseMask | ButtonPressMask; - XSelectInput(dpy, xwin, event_mask); - XtAddEventHandler(xt_w, event_mask, False, (XtEventHandler)xt_event_handler, This); - } -} - -void -makePixmap(PluginInstance *This) -{ - createPixmap(This); - drawPixmap(This); - addXtEventHandler(This); - set_cursor(This); + /* need to check whether we already pop up a dialog box for previous + minetype in the same web page. It's require otherwise there will + be 2 dialog boxes pop if there are 2 plugin in the same web page */ + if (addToList(&head, This->type)) { + gtk_widget_show_all(dialogWindow); + } } diff --git a/mozilla/modules/plugin/default/unix/nullplugin.h b/mozilla/modules/plugin/default/unix/nullplugin.h index 557790d6bc0..72b4f9b0420 100644 --- a/mozilla/modules/plugin/default/unix/nullplugin.h +++ b/mozilla/modules/plugin/default/unix/nullplugin.h @@ -82,13 +82,10 @@ typedef struct _PluginInstance typedef struct _MimeTypeElement { - PluginInstance *pinst; + NPMIMEType value; struct _MimeTypeElement *next; } MimeTypeElement; /* Extern functions */ extern void makeWidget(PluginInstance *This); extern NPMIMEType dupMimeType(NPMIMEType type); -extern void destroyWidget(PluginInstance *This); -extern void makePixmap(PluginInstance *This); - diff --git a/mozilla/modules/plugin/samples/default/unix/Makefile.in b/mozilla/modules/plugin/samples/default/unix/Makefile.in index cfa521e05ae..470e6d86bfd 100644 --- a/mozilla/modules/plugin/samples/default/unix/Makefile.in +++ b/mozilla/modules/plugin/samples/default/unix/Makefile.in @@ -48,7 +48,7 @@ DEFINES += -D_IMPL_NS_PLUGIN include $(topsrcdir)/config/rules.mk -EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) -lXt -lXpm \ +EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) \ $(NULL) ifndef MOZ_MONOLITHIC_TOOLKIT diff --git a/mozilla/modules/plugin/samples/default/unix/npshell.c b/mozilla/modules/plugin/samples/default/unix/npshell.c index 19b0fb5bda3..0be4e6bd3e8 100644 --- a/mozilla/modules/plugin/samples/default/unix/npshell.c +++ b/mozilla/modules/plugin/samples/default/unix/npshell.c @@ -152,6 +152,7 @@ NPP_New(NPMIMEType pluginType, return NPERR_NO_ERROR; } + NPError NPP_Destroy(NPP instance, NPSavedData** save) { @@ -164,8 +165,6 @@ NPP_Destroy(NPP instance, NPSavedData** save) This = (PluginInstance*) instance->pdata; if (This != NULL) { - if (This->dialogBox) - destroyWidget(This); if (This->type) NPN_MemFree(This->type); if (This->pluginsPageUrl) @@ -222,8 +221,10 @@ NPP_SetWindow(NPP instance, NPWindow* window) This->visual = ws_info->visual; This->depth = ws_info->depth; This->colormap = ws_info->colormap; - makePixmap(This); - makeWidget(This); + if (This->exists != TRUE) { + This->exists = FALSE; + makeWidget(This); + } } return NPERR_NO_ERROR; } diff --git a/mozilla/modules/plugin/samples/default/unix/nullplugin.c b/mozilla/modules/plugin/samples/default/unix/nullplugin.c index 3d3c8ffc776..6fb2c2cd7d9 100644 --- a/mozilla/modules/plugin/samples/default/unix/nullplugin.c +++ b/mozilla/modules/plugin/samples/default/unix/nullplugin.c @@ -34,13 +34,6 @@ #include #include - -/* Xlib/Xt stuff */ -#include -#include -#include -#include - #include "npapi.h" #include "nullplugin.h" @@ -49,14 +42,32 @@ /* Global data */ static MimeTypeElement *head = NULL; -/* destroy the dialog box */ -void -destroyWidget(PluginInstance *This) +/* this function is used to clear the mime type cache list + whenever the dialog box is closed. We need to clear the + list in order to have the dialog box pop up again when + the page is reload. (it's because there is no puzzle + icon in unix to let the people actively forward to netscape + page) */ +static void +clearList(MimeTypeElement **typelist) { - if (This && This->dialogBox) - { - gtk_widget_destroy (GTK_WIDGET(This->dialogBox)); + MimeTypeElement *ele; + MimeTypeElement *ele2; + + if (typelist == NULL) + return; + + /* follow the head to free the list */ + ele = *typelist; + while (ele != NULL) { + ele2 = ele->next; + if (ele->value != NULL) + NPN_MemFree(ele->value); + NPN_MemFree(ele); + ele = ele2; } + *typelist = ele; + return; } /* callback function for the OK button */ @@ -88,7 +99,7 @@ DialogOKClicked (GtkButton *button, gpointer data) { /* If necessary, get the default plug-ins page resource */ char* address = This->pluginsPageUrl; - if (address == NULL || *address == 0) + if (address == NULL) { address = PLUGINSPAGE_URL; } @@ -109,14 +120,16 @@ DialogOKClicked (GtkButton *button, gpointer data) NPN_MemFree(url); } } - destroyWidget(This); + gtk_widget_destroy (dialogWindow); + clearList(&head); } /* the call back function for cancel button */ static void DialogCancelClicked (GtkButton *button, gpointer data) { - destroyWidget((PluginInstance*) data); + gtk_widget_destroy (GTK_WIDGET(data)); + clearList(&head); } /* a handy procedure to add a widget and pack it as well */ @@ -134,21 +147,23 @@ AddWidget (GtkWidget *widget, GtkWidget *packingbox) static gboolean isEqual(NPMIMEType t1, NPMIMEType t2) { - return (t1 && t2) ? (strcmp(t1, t2) == 0) : FALSE; + return(strcmp(t1, t2) == 0); } -static MimeTypeElement * +static gboolean isExist(MimeTypeElement **typelist, NPMIMEType type) { MimeTypeElement *ele; + if (typelist == NULL) return FALSE; + ele = *typelist; while (ele != NULL) { - if (isEqual(ele->pinst->type, type)) - return ele; + if (isEqual(ele->value, type)) + return TRUE; ele = ele->next; } - return NULL; + return FALSE; } NPMIMEType @@ -161,58 +176,19 @@ dupMimeType(NPMIMEType type) } static gboolean -addToList(MimeTypeElement **typelist, PluginInstance *This) +addToList(MimeTypeElement **typelist, NPMIMEType type) { - if (This && This->type && !isExist(typelist, This->type)) - { - MimeTypeElement *ele; - if ((ele = (MimeTypeElement *) NPN_MemAlloc(sizeof(MimeTypeElement)))) - { - ele->pinst = This; - ele->next = *typelist; - *typelist = ele; - return(TRUE); - } - } - return(FALSE); -} + MimeTypeElement *ele; -static gboolean -delFromList(MimeTypeElement **typelist, PluginInstance *This) -{ - if (typelist && This) - { - MimeTypeElement *ele_prev; - MimeTypeElement *ele = *typelist; - while (ele) - { - if (isEqual(ele->pinst->type, This->type)) - { - if (*typelist == ele) - { - *typelist = ele->next; - } else { - ele_prev->next = ele->next; - } - NPN_MemFree(ele); - return(TRUE); - } - ele_prev = ele; - ele = ele->next; - } - } - return(FALSE); -} + if (!typelist) return(FALSE); -static void -onDestroyWidget(GtkWidget *w, gpointer data) -{ - PluginInstance* This = (PluginInstance*) data; - if (This && This->dialogBox && This->dialogBox == w) - { - This->dialogBox = 0; - delFromList(&head, This); - } + if (isExist(typelist, type)) return(FALSE); + + ele = (MimeTypeElement *) NPN_MemAlloc(sizeof(MimeTypeElement)); + ele->value = dupMimeType(type); + ele->next = *typelist; + *typelist = ele; + return(TRUE); } /* create and display the dialog box */ @@ -224,37 +200,17 @@ makeWidget(PluginInstance *This) GtkWidget *okButton; GtkWidget *cancelButton; char message[1024]; - MimeTypeElement *ele; if (!This) return; - - /* need to check whether we already pop up a dialog box for previous - minetype in the same web page. It's require otherwise there will - be 2 dialog boxes pop if there are 2 plugin in the same web page - */ - if ((ele = isExist(&head, This->type))) - { - if (ele->pinst && ele->pinst->dialogBox) - { - GtkWidget *top_window = gtk_widget_get_toplevel(ele->pinst->dialogBox); - if (top_window && GTK_WIDGET_VISIBLE(top_window)) - { /* this will raise the toplevel window */ - gdk_window_show(top_window->window); - } - } - return; - } + if (This->exists == TRUE) return; dialogWindow = gtk_dialog_new(); This->dialogBox = dialogWindow; This->exists = TRUE; - This->dialogBox = dialogWindow; - addToList(&head, This); gtk_window_set_title(GTK_WINDOW(dialogWindow), PLUGIN_NAME); - gtk_window_set_position(GTK_WINDOW(dialogWindow), GTK_WIN_POS_CENTER); - gtk_window_set_modal(GTK_WINDOW(dialogWindow), FALSE); - gtk_container_set_border_width(GTK_CONTAINER(dialogWindow), 20); - gtk_window_set_policy(GTK_WINDOW(dialogWindow), FALSE, FALSE, TRUE); + /* gtk_window_set_position(GTK_WINDOW(dialogWindow), GTK_WIN_POS_CENTER); */ + gtk_window_set_modal(GTK_WINDOW(dialogWindow), TRUE); + gtk_container_set_border_width(GTK_CONTAINER(dialogWindow), 0); PR_snprintf(message, sizeof(message) - 1, MESSAGE, This->type); dialogMessage = AddWidget(gtk_label_new (message), @@ -271,145 +227,14 @@ makeWidget(PluginInstance *This) GTK_SIGNAL_FUNC(DialogOKClicked), This); gtk_signal_connect (GTK_OBJECT(cancelButton), "clicked", - GTK_SIGNAL_FUNC(DialogCancelClicked), This); + GTK_SIGNAL_FUNC(DialogCancelClicked), dialogWindow); - /* hookup to when the dialog is destroyed */ - gtk_signal_connect(GTK_OBJECT(dialogWindow), "destroy", - GTK_SIGNAL_FUNC(onDestroyWidget), This); - gtk_widget_show_all(dialogWindow); -} - -/* XPM */ -static char * npnul320_xpm[] = { -"32 32 6 1", -" c None", -". c #808080", -"+ c #F8F8F8", -"@ c #C0C0C0", -"# c #000000", -"$ c #00F8F8", -"........................++++++++", -".++++++++++++++++++++++..+++++++", -".+++++++++++++++++++++@.@.++++++", -".++@@@@@@@@@@@@@@@@@@@@.+@.+++++", -".++@@@@@@@@@.....@@@@@@.++@.++++", -".++@@@@@@@@.+++++#@@@@@.+++@.+++", -".++@@@@@@@.++$$$$$#@@@@.++++@.++", -".++@@@@@@@.+$$$$$$#.@@@.+++++@.+", -".++@@@...@@.+$$$$#..###.#######+", -".++@@.+++$$++$$$$$##++$#......#+", -".++@@.+$$$++$$$$$$$+$$$#......#+", -".++@@.+$$$$$$$$$$$$$$$$#..@@++#+", -".++@@@$$$$$$$$$$$$$$$$#...@@++#+", -".++@@@$#$##.$$$$$$##$$#...@@++#+", -".++@@@@##...$$$$$#..##...@@@++#+", -".++@@@@@....+$$$$#.......@@@++#+", -".++@@@@@@...+$$$$#.@@@..@@@@++#+", -".++@@@@..@@.+$$$$#.@##@@@@@@++#+", -".++@@@.++$$++$$$$$##$$#@@@@@++#+", -".++@@@.+$$++$$$$$$$$$$#@@@@@++#+", -".++@@.++$$$$$$$$$$$$$$$#@@@@++#+", -".++@@.+$$$$$$$$$$$$$$$$#.@@@++#+", -".++@@.+$$##$$$$$$$##$$$#..@@++#+", -".++@@@###...$$$$$#.@###...@@++#+", -".++@@@@....$$$$$$$#.@.....@@++#+", -".++@@@@@...$$$$$$$#..@...@@@++#+", -".++@@@@@@@@#$$$$$#...@@@@@@@++#+", -".++@@@@@@@@@#####...@@@@@@@@++#+", -".++@@@@@@@@@@......@@@@@@@@@++#+", -".+++++++++++++....++++++++++++#+", -".+++++++++++++++++++++++++++++#+", -"###############################+"}; - - -static Pixmap aPixmap = 0, aShapeMask = 0; -static XpmAttributes xpm_attr; -static Cursor cursor = 0; - -static int -createPixmap(PluginInstance *This) -{ - int err = 0; - if (aPixmap) return err; - - xpm_attr.valuemask = 0; - err = XpmCreatePixmapFromData(This->display, This->window, npnul320_xpm, &aPixmap, &aShapeMask, &xpm_attr); - if (err) { - fprintf(stderr, "%s\n", XpmGetErrorString(err)); - } - return err; -} - -static void -drawPixmap(PluginInstance *This) -{ - if (aPixmap) - { - int dest_x = This->width/2 - xpm_attr.width/2; - int dest_y = This->height/2 - xpm_attr.height/2; - if (dest_x >= 0 && dest_y >= 0) - { - GC gc; - gc = XCreateGC(This->display, This->window, 0, NULL); - XCopyArea(This->display, aPixmap, This->window, gc, - 0, 0, xpm_attr.width, xpm_attr.height, dest_x, dest_y); - XFreeGC(This->display, gc); - } - } -} - -static void -set_cursor (PluginInstance *This) -{ - if (!cursor) - { - cursor = XCreateFontCursor(This->display, XC_hand2); - } - if (cursor) - { - XDefineCursor(This->display, This->window, cursor); - } -} - -static void -xt_event_handler(Widget xt_w, PluginInstance *This, XEvent *xevent, Boolean *b) -{ - switch (xevent->type) - { - case Expose: - /* get rid of all other exposure events */ - while(XCheckTypedWindowEvent(This->display, This->window, Expose, xevent)); - drawPixmap(This); - break; - case ButtonRelease: - makeWidget(This); - break; - default: - break; - } -} - -static void -addXtEventHandler(PluginInstance *This) -{ - Display *dpy = (Display*) This->display; - Window xwin = (Window) This->window; - Widget xt_w = XtWindowToWidget(dpy, xwin); - if (xt_w) - { - long event_mask = ExposureMask | ButtonReleaseMask | ButtonPressMask; - XSelectInput(dpy, xwin, event_mask); - XtAddEventHandler(xt_w, event_mask, False, (XtEventHandler)xt_event_handler, This); - } -} - -void -makePixmap(PluginInstance *This) -{ - createPixmap(This); - drawPixmap(This); - addXtEventHandler(This); - set_cursor(This); + /* need to check whether we already pop up a dialog box for previous + minetype in the same web page. It's require otherwise there will + be 2 dialog boxes pop if there are 2 plugin in the same web page */ + if (addToList(&head, This->type)) { + gtk_widget_show_all(dialogWindow); + } } diff --git a/mozilla/modules/plugin/samples/default/unix/nullplugin.h b/mozilla/modules/plugin/samples/default/unix/nullplugin.h index 557790d6bc0..72b4f9b0420 100644 --- a/mozilla/modules/plugin/samples/default/unix/nullplugin.h +++ b/mozilla/modules/plugin/samples/default/unix/nullplugin.h @@ -82,13 +82,10 @@ typedef struct _PluginInstance typedef struct _MimeTypeElement { - PluginInstance *pinst; + NPMIMEType value; struct _MimeTypeElement *next; } MimeTypeElement; /* Extern functions */ extern void makeWidget(PluginInstance *This); extern NPMIMEType dupMimeType(NPMIMEType type); -extern void destroyWidget(PluginInstance *This); -extern void makePixmap(PluginInstance *This); -