2000-07-12 13:53:29 +00:00
|
|
|
/*
|
|
|
|
* The contents of this file are subject to the Mozilla Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Christopher Blizzard.
|
|
|
|
* Portions created by Christopher Blizzard are Copyright (C)
|
|
|
|
* Christopher Blizzard. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Christopher Blizzard <blizzard@mozilla.org>
|
2000-10-12 16:27:52 +00:00
|
|
|
* Brian Edmond <briane@qnx.com>
|
2000-07-12 13:53:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#include <Pt.h>
|
2001-07-04 19:42:06 +00:00
|
|
|
#include <photon/PtWebClient.h>
|
|
|
|
#include "../src/PtMozilla.h"
|
2000-07-12 13:53:29 +00:00
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
int window_count = 0;
|
|
|
|
struct window_info
|
|
|
|
{
|
|
|
|
PtWidget_t *window, *back, *forward, *stop, *web, *reload, *url, *status, \
|
|
|
|
*progress, *print, *sel, *save, *stream;
|
|
|
|
char *statusMessage;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
PtWidget_t *create_browser_window(unsigned window_flags);
|
|
|
|
|
|
|
|
/////////////////// modal authentication dialog /////////////////////////////
|
|
|
|
struct Auth_data
|
|
|
|
{
|
|
|
|
PtWidget_t *awin, *auser, *apass, *aok, *acan;
|
|
|
|
PtModalCtrl_t mc;
|
|
|
|
char *user, *pass;
|
|
|
|
};
|
|
|
|
|
|
|
|
// retrieve user input from authorization dialog
|
|
|
|
int dlg_auth_cb( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo )
|
|
|
|
{
|
|
|
|
struct Auth_data *auth = (struct Auth_data *) data;
|
|
|
|
char *u, *p;
|
|
|
|
|
|
|
|
// check which widget triggered the callback
|
|
|
|
if (widget == auth->aok)
|
|
|
|
{
|
|
|
|
PtGetResource(auth->auser, Pt_ARG_TEXT_STRING, &u, 0);
|
|
|
|
PtGetResource(auth->apass, Pt_ARG_TEXT_STRING, &p, 0);
|
|
|
|
auth->user = strdup(u);
|
|
|
|
auth->pass = strdup(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
PtModalUnblock(&(auth->mc), (int *)1);
|
|
|
|
|
|
|
|
return (Pt_CONTINUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
int CreateAuthWindow(PtMozillaAuthenticateCb_t *acb, PtWidget_t *parent)
|
|
|
|
{
|
|
|
|
PhArea_t area = {{0, 0}, {310, 100}};
|
|
|
|
PtWidget_t *awin, *auser, *apass;
|
|
|
|
PtArg_t args[5];
|
|
|
|
struct Auth_data *auth = (struct Auth_data *)calloc (sizeof(struct Auth_data), 1);
|
|
|
|
int response;
|
|
|
|
|
|
|
|
// window
|
|
|
|
PtSetArg(&args[0], Pt_ARG_DIM, &(area.size), 0);
|
|
|
|
PtSetArg(&args[1], Pt_ARG_WINDOW_TITLE, "Authentication", 0);
|
|
|
|
auth->awin = PtCreateWidget(PtWindow, parent, 2, args);
|
|
|
|
|
|
|
|
// labels
|
|
|
|
area.pos.x = 7;
|
|
|
|
area.pos.y = 7;
|
|
|
|
PtSetArg(&args[0], Pt_ARG_POS, &area.pos, 0);
|
|
|
|
PtSetArg(&args[1], Pt_ARG_TEXT_STRING, "Username:", 0);
|
|
|
|
PtCreateWidget(PtLabel, auth->awin, 2, args);
|
|
|
|
area.pos.y += 30;
|
|
|
|
PtSetArg(&args[0], Pt_ARG_POS, &area.pos, 0);
|
|
|
|
PtSetArg(&args[1], Pt_ARG_TEXT_STRING, "Password:", 0);
|
|
|
|
PtCreateWidget(PtLabel, auth->awin, 2, args);
|
|
|
|
|
|
|
|
// fields
|
|
|
|
area.pos.x = 90;
|
|
|
|
area.pos.y = 5;
|
|
|
|
area.size.w = 210;
|
|
|
|
area.size.h = 20;
|
|
|
|
PtSetArg(&args[0], Pt_ARG_AREA, &area, 0);
|
|
|
|
auth->auser = PtCreateWidget(PtText, auth->awin, 1, args);
|
|
|
|
area.pos.y += 30;
|
|
|
|
PtSetArg(&args[0], Pt_ARG_AREA, &area, 0);
|
|
|
|
auth->apass = PtCreateWidget(PtText, auth->awin, 1, args);
|
|
|
|
|
|
|
|
// buttons
|
|
|
|
area.pos.x = 155;
|
|
|
|
area.pos.y = 68;
|
|
|
|
area.size.w = 70;
|
|
|
|
area.size.h = 21;
|
|
|
|
PtSetArg(&args[0], Pt_ARG_AREA, &area, 0);
|
|
|
|
PtSetArg(&args[1], Pt_ARG_TEXT_STRING, "Ok", 0);
|
|
|
|
auth->aok = PtCreateWidget(PtButton, auth->awin, 2, args);
|
|
|
|
PtAddCallback(auth->aok, Pt_CB_ACTIVATE, dlg_auth_cb, auth);
|
|
|
|
area.pos.x += 75;
|
|
|
|
PtSetArg(&args[0], Pt_ARG_AREA, &area, 0);
|
|
|
|
PtSetArg(&args[1], Pt_ARG_TEXT_STRING, "Cancel", 0);
|
|
|
|
auth->acan = PtCreateWidget(PtButton, auth->awin, 2, args);
|
|
|
|
PtAddCallback(auth->acan, Pt_CB_ACTIVATE, dlg_auth_cb, auth);
|
|
|
|
|
|
|
|
PtRealizeWidget(auth->awin);
|
|
|
|
|
|
|
|
response = (int) PtModalBlock(&(auth->mc), 0);
|
|
|
|
PtDestroyWidget(auth->awin);
|
|
|
|
if (auth->user && auth->pass)
|
|
|
|
{
|
|
|
|
strcpy(acb->user, auth->user);
|
|
|
|
strcpy(acb->pass, auth->pass);
|
|
|
|
free(auth->user);
|
|
|
|
free(auth->pass);
|
|
|
|
free(auth);
|
|
|
|
return (Pt_CONTINUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(auth);
|
|
|
|
return (Pt_END);
|
|
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/////////////// callbacks for the main window controls ///////////////////////
|
|
|
|
|
|
|
|
int window_close_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
|
|
|
{
|
|
|
|
window_count--;
|
|
|
|
if (window_count == 0)
|
|
|
|
exit (0);
|
|
|
|
return (Pt_CONTINUE);
|
|
|
|
}
|
2000-07-12 13:53:29 +00:00
|
|
|
|
|
|
|
int reload_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
|
|
|
{
|
|
|
|
PtArg_t args[1];
|
2001-07-04 19:42:06 +00:00
|
|
|
struct window_info *info;
|
|
|
|
PtGetResource(PtWidgetParent(widget), Pt_ARG_POINTER, &info, 0);
|
2000-07-12 13:53:29 +00:00
|
|
|
PtSetArg(&args[0], Pt_ARG_MOZ_RELOAD, 0, 0);
|
2001-07-04 19:42:06 +00:00
|
|
|
PtSetResources(info->web, 1, args);
|
2000-07-12 13:53:29 +00:00
|
|
|
return (Pt_CONTINUE);
|
|
|
|
}
|
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
int print_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
|
|
|
{
|
|
|
|
PtArg_t args[1];
|
|
|
|
struct window_info *info;
|
|
|
|
PtGetResource(PtWidgetParent(widget), Pt_ARG_POINTER, &info, 0);
|
|
|
|
PtSetArg(&args[0], Pt_ARG_MOZ_PRINT, 0, 0);
|
|
|
|
PtSetResources(info->web, 1, args);
|
|
|
|
return (Pt_CONTINUE);
|
|
|
|
}
|
|
|
|
|
2000-07-12 13:53:29 +00:00
|
|
|
int stop_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
|
|
|
{
|
|
|
|
PtArg_t args[1];
|
2001-07-04 19:42:06 +00:00
|
|
|
struct window_info *info;
|
|
|
|
PtGetResource(PtWidgetParent(widget), Pt_ARG_POINTER, &info, 0);
|
2000-07-12 13:53:29 +00:00
|
|
|
PtSetArg(&args[0], Pt_ARG_MOZ_STOP, 0, 0);
|
2001-07-04 19:42:06 +00:00
|
|
|
PtSetResources(info->web, 1, args);
|
2000-07-12 13:53:29 +00:00
|
|
|
return (Pt_CONTINUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
int back_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
|
|
|
{
|
|
|
|
PtArg_t args[1];
|
2001-07-04 19:42:06 +00:00
|
|
|
struct window_info *info;
|
|
|
|
PtGetResource(PtWidgetParent(widget), Pt_ARG_POINTER, &info, 0);
|
2000-07-12 13:53:29 +00:00
|
|
|
PtSetArg(&args[0], Pt_ARG_MOZ_NAVIGATE_PAGE, WWW_DIRECTION_BACK, 0);
|
2001-07-04 19:42:06 +00:00
|
|
|
PtSetResources(info->web, 1, args);
|
2000-07-12 13:53:29 +00:00
|
|
|
return (Pt_CONTINUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
int forward_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
|
|
|
{
|
|
|
|
PtArg_t args[1];
|
2001-07-04 19:42:06 +00:00
|
|
|
struct window_info *info;
|
|
|
|
PtGetResource(PtWidgetParent(widget), Pt_ARG_POINTER, &info, 0);
|
2000-07-12 13:53:29 +00:00
|
|
|
PtSetArg(&args[0], Pt_ARG_MOZ_NAVIGATE_PAGE, WWW_DIRECTION_FWD, 0);
|
2001-07-04 19:42:06 +00:00
|
|
|
PtSetResources(info->web, 1, args);
|
2000-07-12 13:53:29 +00:00
|
|
|
return (Pt_CONTINUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
int load_url_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
|
|
|
{
|
|
|
|
PtTextCallback_t *tcb = (PtTextCallback_t *)cbinfo->cbdata;
|
|
|
|
PtArg_t args[1];
|
2001-07-04 19:42:06 +00:00
|
|
|
struct window_info *info;
|
|
|
|
PtGetResource(PtWidgetParent(widget), Pt_ARG_POINTER, &info, 0);
|
2000-07-12 13:53:29 +00:00
|
|
|
|
|
|
|
PtSetArg(&args[0], Pt_ARG_MOZ_GET_URL, tcb->text, 0);
|
2001-07-04 19:42:06 +00:00
|
|
|
PtSetResources(info->web, 1, args);
|
2000-07-12 13:53:29 +00:00
|
|
|
return (Pt_CONTINUE);
|
|
|
|
}
|
2000-10-12 16:27:52 +00:00
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
int select_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
|
|
|
{
|
|
|
|
PtArg_t args[1];
|
|
|
|
struct window_info *info;
|
2000-10-12 16:27:52 +00:00
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
PtGetResource(PtWidgetParent(widget), Pt_ARG_POINTER, &info, 0);
|
|
|
|
PtSetArg(&args[0], Pt_ARG_MOZ_COMMAND, Pt_MOZ_COMMAND_SELECTALL, 0);
|
|
|
|
PtSetResources(info->web, 1, args);
|
2000-10-12 16:27:52 +00:00
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
return (Pt_CONTINUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
int save_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
2000-10-12 16:27:52 +00:00
|
|
|
{
|
2001-07-04 19:42:06 +00:00
|
|
|
PtArg_t args[1];
|
|
|
|
struct window_info *info;
|
|
|
|
PtFileSelectionInfo_t i;
|
|
|
|
char *home = getenv("HOME");
|
|
|
|
|
|
|
|
PtGetResource(PtWidgetParent(widget), Pt_ARG_POINTER, &info, 0);
|
|
|
|
|
|
|
|
memset (&i, 0, sizeof(PtFileSelectionInfo_t));
|
|
|
|
PtFileSelection(info->window, NULL, "Save Page As", home, "*.html,*.txt", \
|
|
|
|
NULL, NULL, NULL, &i, Pt_FSR_NO_FCHECK);
|
|
|
|
|
|
|
|
if (strstr(i.path, ".html"))
|
|
|
|
MozSavePageAs(info->web, i.path, Pt_MOZ_SAVEAS_HTML);
|
|
|
|
else
|
|
|
|
MozSavePageAs(info->web, i.path, Pt_MOZ_SAVEAS_TEXT);
|
|
|
|
|
|
|
|
return (Pt_CONTINUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
//////////////////// mozilla widget callbacks ///////////////////////////////
|
|
|
|
int moz_info_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
|
|
|
{
|
|
|
|
PtMozillaInfoCb_t *info = (PtMozillaInfoCb_t *) cbinfo->cbdata;
|
|
|
|
PtMozillaInfoCb_t *s = (PtMozillaInfoCb_t *) cbinfo->cbdata;
|
|
|
|
struct window_info *i;
|
|
|
|
PtGetResource(PtWidgetParent(widget), Pt_ARG_POINTER, &i, 0);
|
2000-10-12 16:27:52 +00:00
|
|
|
|
|
|
|
switch (s->type)
|
|
|
|
{
|
2001-07-04 19:42:06 +00:00
|
|
|
case Pt_MOZ_INFO_LINK:
|
|
|
|
case Pt_MOZ_INFO_JSSTATUS:
|
|
|
|
if (i->status)
|
|
|
|
PtSetResource(i->status, Pt_ARG_TEXT_STRING, info->data, 0);
|
2000-10-12 16:27:52 +00:00
|
|
|
break;
|
2001-07-04 19:42:06 +00:00
|
|
|
case Pt_MOZ_INFO_TITLE:
|
|
|
|
PtSetResource(i->window, Pt_ARG_WINDOW_TITLE, info->data, 0);
|
|
|
|
break;
|
|
|
|
case Pt_MOZ_INFO_SSL:
|
|
|
|
printf("SSL status: ");
|
|
|
|
if (info->status & Pt_SSL_STATE_IS_INSECURE)
|
|
|
|
printf("INSECURE ");
|
|
|
|
if (info->status & Pt_SSL_STATE_IS_BROKEN)
|
|
|
|
printf("BROKEN ");
|
|
|
|
if (info->status & Pt_SSL_STATE_IS_SECURE)
|
|
|
|
printf("SECURE ");
|
|
|
|
if (info->status & Pt_SSL_STATE_SECURE_HIGH)
|
|
|
|
printf("HIGH ");
|
|
|
|
if (info->status & Pt_SSL_STATE_SECURE_MED)
|
|
|
|
printf("MED ");
|
|
|
|
if (info->status & Pt_SSL_STATE_SECURE_LOW)
|
|
|
|
printf("LOW ");
|
|
|
|
printf("\n");
|
2000-10-12 16:27:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (Pt_CONTINUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
int moz_start_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
|
|
|
{
|
2001-07-04 19:42:06 +00:00
|
|
|
struct window_info *i;
|
|
|
|
PtGetResource(PtWidgetParent(widget), Pt_ARG_POINTER, &i, 0);
|
2000-10-12 16:27:52 +00:00
|
|
|
// could start an animation here
|
2001-07-04 19:42:06 +00:00
|
|
|
if (i->status)
|
|
|
|
PtSetResource(i->status, Pt_ARG_TEXT_STRING, "Starting to load page", 0);
|
|
|
|
if (i->stop)
|
|
|
|
PtSetResource(i->stop, Pt_ARG_FLAGS, 0, Pt_BLOCKED|Pt_GHOST);
|
2000-10-12 16:27:52 +00:00
|
|
|
|
|
|
|
return (Pt_CONTINUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
int moz_complete_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
|
|
|
{
|
2001-07-04 19:42:06 +00:00
|
|
|
struct window_info *i;
|
|
|
|
PtGetResource(PtWidgetParent(widget), Pt_ARG_POINTER, &i, 0);
|
|
|
|
if (i->status)
|
|
|
|
PtSetResource(i->status, Pt_ARG_TEXT_STRING, "Done", 0);
|
2000-10-12 16:27:52 +00:00
|
|
|
|
|
|
|
// could stop an animation here
|
2001-07-04 19:42:06 +00:00
|
|
|
if (i->stop)
|
|
|
|
PtSetResource(i->stop, Pt_ARG_FLAGS, ~0, Pt_BLOCKED|Pt_GHOST);
|
2000-10-12 16:27:52 +00:00
|
|
|
|
|
|
|
return (Pt_CONTINUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
int moz_progress_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
|
|
|
{
|
|
|
|
PtMozillaProgressCb_t *c = (PtMozillaProgressCb_t *) cbinfo->cbdata;
|
|
|
|
int percent;
|
|
|
|
char message[256];
|
2001-07-04 19:42:06 +00:00
|
|
|
struct window_info *i;
|
|
|
|
PtGetResource(PtWidgetParent(widget), Pt_ARG_POINTER, &i, 0);
|
2000-10-12 16:27:52 +00:00
|
|
|
|
|
|
|
if ((c->max <= 0) || (c->cur > c->max))
|
|
|
|
{
|
|
|
|
percent = 0;
|
2001-07-04 19:42:06 +00:00
|
|
|
sprintf(message, "%s (%d bytes loaded)", i->statusMessage, c->cur);
|
2000-10-12 16:27:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
percent = (c->cur*100)/c->max;
|
2001-07-04 19:42:06 +00:00
|
|
|
sprintf(message, "%s (%d%% complete, %d bytes of %d loaded)", i->statusMessage, percent, c->cur, c->max);
|
2000-10-12 16:27:52 +00:00
|
|
|
}
|
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
if (i->progress)
|
|
|
|
PtSetResource(i->progress, Pt_ARG_GAUGE_VALUE, percent, 0);
|
|
|
|
if (i->status)
|
|
|
|
PtSetResource(i->status, Pt_ARG_TEXT_STRING, message, 0);
|
2000-10-12 16:27:52 +00:00
|
|
|
|
|
|
|
return (Pt_CONTINUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
int moz_url_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
|
|
|
{
|
|
|
|
int *nflags = NULL;
|
|
|
|
PtMozillaUrlCb_t *c = (PtMozillaUrlCb_t *) cbinfo->cbdata;
|
2001-07-04 19:42:06 +00:00
|
|
|
struct window_info *i;
|
|
|
|
PtGetResource(PtWidgetParent(widget), Pt_ARG_POINTER, &i, 0);
|
2000-10-12 16:27:52 +00:00
|
|
|
|
|
|
|
// display the url in the entry field
|
2001-07-04 19:42:06 +00:00
|
|
|
if (i->url)
|
|
|
|
PtSetResource(i->url, Pt_ARG_TEXT_STRING, c->url, 0);
|
2000-10-12 16:27:52 +00:00
|
|
|
|
|
|
|
/* get the navigation possibilities */
|
2001-07-04 19:42:06 +00:00
|
|
|
PtGetResource(i->web, Pt_ARG_MOZ_NAVIGATE_PAGE, &nflags, 0 );
|
2000-10-12 16:27:52 +00:00
|
|
|
|
|
|
|
if ( nflags != NULL )
|
|
|
|
{
|
|
|
|
// disable or enable the forward and back buttons accordingly
|
2001-07-04 19:42:06 +00:00
|
|
|
if (i->back)
|
|
|
|
{
|
|
|
|
if (*nflags & WWW_DIRECTION_BACK)
|
|
|
|
PtSetResource(i->back, Pt_ARG_FLAGS, 0, Pt_BLOCKED|Pt_GHOST);
|
|
|
|
else
|
|
|
|
PtSetResource(i->back, Pt_ARG_FLAGS, ~0, Pt_BLOCKED|Pt_GHOST);
|
|
|
|
}
|
|
|
|
if (i->forward)
|
|
|
|
{
|
|
|
|
if (*nflags & WWW_DIRECTION_FWD)
|
|
|
|
PtSetResource(i->forward, Pt_ARG_FLAGS, 0, Pt_BLOCKED|Pt_GHOST);
|
|
|
|
else
|
|
|
|
PtSetResource(i->forward, Pt_ARG_FLAGS, ~0, Pt_BLOCKED|Pt_GHOST);
|
|
|
|
}
|
2000-10-12 16:27:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (Pt_CONTINUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
int moz_net_state_change_cb (PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
|
|
|
{
|
|
|
|
PtMozillaNetStateCb_t *c = (PtMozillaNetStateCb_t *) cbinfo->cbdata;
|
2001-07-04 19:42:06 +00:00
|
|
|
struct window_info *i;
|
|
|
|
PtGetResource(PtWidgetParent(widget), Pt_ARG_POINTER, &i, 0);
|
2000-10-12 16:27:52 +00:00
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
i->statusMessage = NULL;
|
2000-10-12 16:27:52 +00:00
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
#if 0
|
|
|
|
if (c->flags & STATE_REQUEST)
|
2000-10-12 16:27:52 +00:00
|
|
|
{
|
2001-07-04 19:42:06 +00:00
|
|
|
if (c->flags & STATE_REDIRECTING)
|
2000-10-12 16:27:52 +00:00
|
|
|
statusMessage = "Redirecting to site...";
|
2001-07-04 19:42:06 +00:00
|
|
|
else if (c->flags & STATE_TRANSFERRING)
|
2000-10-12 16:27:52 +00:00
|
|
|
statusMessage = "Transferring data from site...";
|
2001-07-04 19:42:06 +00:00
|
|
|
else if (c->flags & STATE_NEGOTIATING)
|
2000-10-12 16:27:52 +00:00
|
|
|
statusMessage = "Waiting for authorization...";
|
|
|
|
}
|
2000-07-12 13:53:29 +00:00
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
if (c->status == STATEFAILED_DNS)
|
2000-10-12 16:27:52 +00:00
|
|
|
statusMessage = "Site not found.";
|
2001-07-04 19:42:06 +00:00
|
|
|
else if (c->status == STATEFAILED_CONNECT)
|
2000-10-12 16:27:52 +00:00
|
|
|
statusMessage = "Failed to connect to site.";
|
2001-07-04 19:42:06 +00:00
|
|
|
else if (c->status == STATEFAILED_TIMEOUT)
|
2000-10-12 16:27:52 +00:00
|
|
|
statusMessage = "Failed due to connection timeout.";
|
2001-07-04 19:42:06 +00:00
|
|
|
else if (c->status == STATEFAILED_USERCANCELED)
|
2000-10-12 16:27:52 +00:00
|
|
|
statusMessage = "User canceled connecting to site.";
|
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
if (c->flags & STATE_WINDOW)
|
2000-10-12 16:27:52 +00:00
|
|
|
{
|
2001-07-04 19:42:06 +00:00
|
|
|
if (c->flags & STATE_START)
|
2000-10-12 16:27:52 +00:00
|
|
|
statusMessage = "Loading site...";
|
2001-07-04 19:42:06 +00:00
|
|
|
else if (c->flags & STATE_STOP)
|
2000-10-12 16:27:52 +00:00
|
|
|
statusMessage = "Done.";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (statusMessage)
|
|
|
|
PtSetResource(status, Pt_ARG_TEXT_STRING, statusMessage, 0);
|
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
#endif
|
2000-10-12 16:27:52 +00:00
|
|
|
return (Pt_CONTINUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
int moz_new_window_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
|
|
|
{
|
|
|
|
PtMozillaNewWindowCb_t *c = (PtMozillaNewWindowCb_t *) cbinfo->cbdata;
|
2001-07-04 19:42:06 +00:00
|
|
|
struct window_info *i;
|
|
|
|
PtWidget_t *win;
|
2000-10-12 16:27:52 +00:00
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
win = create_browser_window(c->window_flags);
|
|
|
|
if (win)
|
|
|
|
{
|
|
|
|
PtGetResource(win, Pt_ARG_POINTER, &i, 0);
|
|
|
|
c->widget = i->web;
|
|
|
|
return (Pt_CONTINUE);
|
|
|
|
}
|
2000-10-12 16:27:52 +00:00
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
return (Pt_END);
|
2000-10-12 16:27:52 +00:00
|
|
|
}
|
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
int moz_visibility_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
2000-10-12 16:27:52 +00:00
|
|
|
{
|
2001-07-04 19:42:06 +00:00
|
|
|
PtMozillaVisibilityCb_t *v = (PtMozillaVisibilityCb_t *) cbinfo->cbdata;
|
|
|
|
struct window_info *i;
|
2000-10-12 16:27:52 +00:00
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
PtGetResource(PtWidgetParent(widget), Pt_ARG_POINTER, &i, 0);
|
|
|
|
if (v->show)
|
|
|
|
PtRealizeWidget(i->window);
|
|
|
|
else
|
|
|
|
PtUnrealizeWidget(i->window);
|
2000-10-12 16:27:52 +00:00
|
|
|
|
|
|
|
return (Pt_CONTINUE);
|
|
|
|
}
|
2001-07-04 19:42:06 +00:00
|
|
|
int moz_open_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
2000-10-12 16:27:52 +00:00
|
|
|
{
|
2001-07-04 19:42:06 +00:00
|
|
|
int *nflags = NULL;
|
|
|
|
PtMozillaUrlCb_t *c = (PtMozillaUrlCb_t *) cbinfo->cbdata;
|
2000-10-12 16:27:52 +00:00
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
// return Pt_END to prevent this page from loading
|
|
|
|
if (strcmp(c->url, "http://www.google.com/") == 0)
|
|
|
|
{
|
|
|
|
PtAskQuestion(NULL, "Open URL Callback", "You can't go to google.", \
|
|
|
|
NULL, "OK", NULL, NULL, 1);
|
|
|
|
return (Pt_END);
|
|
|
|
}
|
2000-10-12 16:27:52 +00:00
|
|
|
|
|
|
|
return (Pt_CONTINUE);
|
|
|
|
}
|
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
int moz_auth_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
2000-10-12 16:27:52 +00:00
|
|
|
{
|
2001-07-04 19:42:06 +00:00
|
|
|
PtMozillaAuthenticateCb_t *a = (PtMozillaAuthenticateCb_t *) cbinfo->cbdata;
|
|
|
|
|
|
|
|
return (CreateAuthWindow(a, PtWidgetParent(widget)));
|
|
|
|
}
|
|
|
|
|
|
|
|
int moz_dialog_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
|
|
|
{
|
|
|
|
PtMozillaDialogCb_t *d = (PtMozillaDialogCb_t *) cbinfo->cbdata;
|
|
|
|
|
|
|
|
switch (d->type)
|
|
|
|
{
|
|
|
|
case Pt_MOZ_DIALOG_ALERT:
|
|
|
|
PtAskQuestion(NULL, "JS Alert", (d->text) ? d->text : "Alert Message.", \
|
|
|
|
NULL, "OK", NULL, NULL, 1);
|
|
|
|
break;
|
|
|
|
case Pt_MOZ_DIALOG_ALERT_CHECK:
|
|
|
|
printf("Alert Check\n");
|
|
|
|
printf("\tMessage: %s\n", d->message);
|
|
|
|
break;
|
|
|
|
case Pt_MOZ_DIALOG_CONFIRM:
|
|
|
|
if (PtAskQuestion(NULL, "JS Confirm", (d->text) ? d->text : "Confirm Message.", \
|
|
|
|
NULL, "Yes", "No", NULL, 1) == 1)
|
|
|
|
{
|
|
|
|
return (Pt_CONTINUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return (Pt_END);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Pt_MOZ_DIALOG_CONFIRM_CHECK:
|
|
|
|
printf("Confirm Check\n");
|
|
|
|
printf("\tMessage: %s\n", d->message);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (Pt_END);
|
|
|
|
}
|
|
|
|
|
|
|
|
int moz_prompt_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
|
|
|
{
|
|
|
|
PtMozillaPromptCb_t *p = (PtMozillaPromptCb_t *) cbinfo->cbdata;
|
|
|
|
int answer;
|
|
|
|
char *btns[] = { "&Ok", "&Cancel" };
|
|
|
|
char text[128];
|
|
|
|
int len = 127;
|
|
|
|
struct window_info *i;
|
|
|
|
PtGetResource(PtWidgetParent(widget), Pt_ARG_POINTER, &i, 0);
|
2000-10-12 16:27:52 +00:00
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
if (p->dflt_resp)
|
|
|
|
strcpy(text, p->dflt_resp);
|
2000-10-12 16:27:52 +00:00
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
answer = PtPrompt(i->window, NULL, "User Prompt", NULL, (p->text) ? p->text : "Prompt Message.", \
|
|
|
|
NULL, 2, (char const **)btns, NULL, 1, 2, len, text, NULL, NULL, 0 );
|
|
|
|
|
|
|
|
switch( answer )
|
|
|
|
{
|
|
|
|
case 1: // ok
|
|
|
|
strcpy(p->response, text);
|
|
|
|
return (Pt_CONTINUE);
|
|
|
|
break;
|
|
|
|
case 2: // cancel
|
|
|
|
default:
|
|
|
|
return (Pt_END);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (Pt_END);
|
|
|
|
}
|
|
|
|
|
|
|
|
int moz_destroy_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
|
|
|
{
|
|
|
|
PtDestroyWidget(PtWidgetParent(widget));
|
2000-10-12 16:27:52 +00:00
|
|
|
return (Pt_CONTINUE);
|
|
|
|
}
|
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
int moz_context_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
2000-10-12 16:27:52 +00:00
|
|
|
{
|
2001-07-04 19:42:06 +00:00
|
|
|
PtMozillaContextCb_t *c = (PtMozillaContextCb_t *) cbinfo->cbdata;
|
|
|
|
|
|
|
|
printf("Context Callback:\n");
|
|
|
|
if (c->flags & Pt_MOZ_CONTEXT_LINK)
|
|
|
|
printf("\tLINK\n");
|
|
|
|
if (c->flags & Pt_MOZ_CONTEXT_IMAGE)
|
|
|
|
printf("\tIMAGE\n");
|
|
|
|
if (c->flags & Pt_MOZ_CONTEXT_DOCUMENT)
|
|
|
|
printf("\tDOCUMENT\n");
|
|
|
|
if (c->flags & Pt_MOZ_CONTEXT_TEXT)
|
|
|
|
printf("\tTEXT\n");
|
|
|
|
if (c->flags & Pt_MOZ_CONTEXT_INPUT)
|
|
|
|
printf("\tINPUT\n");
|
2000-10-12 16:27:52 +00:00
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
return (Pt_CONTINUE);
|
|
|
|
}
|
2000-10-12 16:27:52 +00:00
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
int moz_print_status_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo)
|
|
|
|
{
|
|
|
|
PtMozillaPrintStatusCb_t *c = (PtMozillaPrintStatusCb_t *) cbinfo->cbdata;
|
2000-10-12 16:27:52 +00:00
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
switch (c->status)
|
|
|
|
{
|
|
|
|
case Pt_MOZ_PRINT_START:
|
|
|
|
printf("Printing: start\n");
|
|
|
|
break;
|
|
|
|
case Pt_MOZ_PRINT_COMPLETE:
|
|
|
|
printf("Printing: complete\n");
|
|
|
|
break;
|
|
|
|
case Pt_MOZ_PRINT_PROGRESS:
|
|
|
|
printf("Printing: progress %d-%d\n", c->cur, c->max);
|
|
|
|
break;
|
|
|
|
}
|
2000-10-12 16:27:52 +00:00
|
|
|
|
|
|
|
return (Pt_CONTINUE);
|
|
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2000-07-12 13:53:29 +00:00
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
|
|
|
|
///////////////////////////////// create a main window //////////////////////
|
|
|
|
PtWidget_t *create_browser_window(unsigned window_flags)
|
2000-07-12 13:53:29 +00:00
|
|
|
{
|
|
|
|
int n = 0;
|
|
|
|
PtArg_t args[10];
|
2001-07-04 19:42:06 +00:00
|
|
|
PhDim_t win_dim = {750, 700};
|
2000-07-12 13:53:29 +00:00
|
|
|
PhArea_t area = {{0, 0}, {70, 25}};
|
2001-07-04 19:42:06 +00:00
|
|
|
struct window_info *info = (struct window_info *) calloc (sizeof(struct window_info), 1);
|
|
|
|
int render = 0;
|
2000-07-12 13:53:29 +00:00
|
|
|
|
2000-10-12 16:27:52 +00:00
|
|
|
// main window creation
|
2000-07-12 13:53:29 +00:00
|
|
|
PtSetArg(&args[n++], Pt_ARG_TITLE, "PtMozilla Test\n", 0);
|
|
|
|
PtSetArg(&args[n++], Pt_ARG_DIM, &win_dim, 0);
|
2001-07-04 19:42:06 +00:00
|
|
|
PtSetArg(&args[n++], Pt_ARG_POINTER, info, 0);
|
|
|
|
info->window = PtCreateWidget(PtWindow, NULL, n, args);
|
|
|
|
PtAddCallback(info->window, Pt_CB_WINDOW_CLOSING, window_close_cb, NULL);
|
2000-07-12 13:53:29 +00:00
|
|
|
|
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
if (window_flags & Pt_MOZ_FLAG_TOOLBARON)
|
|
|
|
{
|
|
|
|
// back button
|
|
|
|
n = 0;
|
|
|
|
PtSetArg(&args[n++], Pt_ARG_AREA, &area, 0);
|
|
|
|
PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, "Back", 0);
|
|
|
|
|
|
|
|
if (window_flags & Pt_MOZ_FLAG_WINDOWBORDERSON)
|
|
|
|
render |= Ph_WM_RENDER_BORDER;
|
|
|
|
if (window_flags & Pt_MOZ_FLAG_WINDOWCLOSEON)
|
|
|
|
render |= Ph_WM_RENDER_CLOSE;
|
|
|
|
// if (window_flags & Pt_MOZ_FLAG_WINDOWRESIZEON)
|
|
|
|
render |= Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX;
|
|
|
|
if (window_flags & Pt_MOZ_FLAG_TITLEBARON)
|
|
|
|
render |= Ph_WM_RENDER_TITLE;
|
|
|
|
|
|
|
|
PtSetArg(&args[n++], Pt_ARG_WINDOW_RENDER_FLAGS, ~0, render);
|
|
|
|
info->back = PtCreateWidget(PtButton, info->window, n, args);
|
|
|
|
PtAddCallback(info->back, Pt_CB_ACTIVATE, back_cb, NULL);
|
|
|
|
|
|
|
|
// forward button
|
|
|
|
n = 0;
|
|
|
|
area.pos.x += 71;
|
|
|
|
PtSetArg(&args[n++], Pt_ARG_AREA, &area, 0);
|
|
|
|
PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, "Forward", 0);
|
|
|
|
info->forward = PtCreateWidget(PtButton, info->window, n, args);
|
|
|
|
PtAddCallback(info->forward, Pt_CB_ACTIVATE, forward_cb, NULL);
|
|
|
|
|
|
|
|
// reload button
|
|
|
|
n = 0;
|
|
|
|
area.pos.x += 71;
|
|
|
|
PtSetArg(&args[n++], Pt_ARG_AREA, &area, 0);
|
|
|
|
PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, "Reload", 0);
|
|
|
|
info->reload = PtCreateWidget(PtButton, info->window, n, args);
|
|
|
|
PtAddCallback(info->reload, Pt_CB_ACTIVATE, reload_cb, NULL);
|
|
|
|
|
|
|
|
// stop button
|
|
|
|
n = 0;
|
|
|
|
area.pos.x += 71;
|
|
|
|
PtSetArg(&args[n++], Pt_ARG_AREA, &area, 0);
|
|
|
|
PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, "Stop", 0);
|
|
|
|
info->stop = PtCreateWidget(PtButton, info->window, n, args);
|
|
|
|
PtAddCallback(info->stop, Pt_CB_ACTIVATE, stop_cb, NULL);
|
|
|
|
|
|
|
|
// print button
|
|
|
|
n = 0;
|
|
|
|
area.pos.x += 71;
|
|
|
|
PtSetArg(&args[n++], Pt_ARG_AREA, &area, 0);
|
|
|
|
PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, "Print", 0);
|
|
|
|
info->print = PtCreateWidget(PtButton, info->window, n, args);
|
|
|
|
PtAddCallback(info->print, Pt_CB_ACTIVATE, print_cb, NULL);
|
|
|
|
|
|
|
|
// select button
|
|
|
|
n = 0;
|
|
|
|
area.pos.x += 71;
|
|
|
|
PtSetArg(&args[n++], Pt_ARG_AREA, &area, 0);
|
|
|
|
PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, "Select", 0);
|
|
|
|
info->sel = PtCreateWidget(PtButton, info->window, n, args);
|
|
|
|
PtAddCallback(info->sel, Pt_CB_ACTIVATE, select_cb, NULL);
|
|
|
|
|
|
|
|
// save as button
|
|
|
|
n = 0;
|
|
|
|
area.pos.x += 71;
|
|
|
|
PtSetArg(&args[n++], Pt_ARG_AREA, &area, 0);
|
|
|
|
PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, "Save", 0);
|
|
|
|
info->save = PtCreateWidget(PtButton, info->window, n, args);
|
|
|
|
PtAddCallback(info->save, Pt_CB_ACTIVATE, save_cb, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (window_flags & Pt_MOZ_FLAG_LOCATIONBARON)
|
|
|
|
{
|
|
|
|
// url entry field
|
|
|
|
n = 0;
|
|
|
|
area.pos.x += 71;
|
|
|
|
area.size.w = win_dim.w - area.pos.x - 2;
|
|
|
|
PtSetArg(&args[n++], Pt_ARG_AREA, &area, 0);
|
|
|
|
PtSetArg(&args[n++], Pt_ARG_ANCHOR_FLAGS, ~0, Pt_RIGHT_ANCHORED_RIGHT|Pt_LEFT_ANCHORED_LEFT| \
|
|
|
|
Pt_TOP_ANCHORED_TOP);
|
|
|
|
info->url = PtCreateWidget(PtText, info->window, n, args);
|
|
|
|
PtAddCallback(info->url, Pt_CB_ACTIVATE, load_url_cb, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (window_flags & Pt_MOZ_FLAG_STATUSBARON)
|
|
|
|
{
|
|
|
|
// status field
|
|
|
|
n = 0;
|
|
|
|
area.pos.x = 0;
|
|
|
|
area.pos.y = win_dim.h - 22;
|
|
|
|
area.size.w = win_dim.w - 100;
|
|
|
|
area.size.h = 22;
|
|
|
|
PtSetArg(&args[n++], Pt_ARG_AREA, &area, 0);
|
|
|
|
PtSetArg(&args[n++], Pt_ARG_ANCHOR_FLAGS, ~0, Pt_RIGHT_ANCHORED_RIGHT|Pt_LEFT_ANCHORED_LEFT| \
|
|
|
|
Pt_TOP_ANCHORED_BOTTOM);
|
|
|
|
info->status = PtCreateWidget(PtLabel, info->window, n, args);
|
|
|
|
|
|
|
|
// progress bar
|
|
|
|
n = 0;
|
|
|
|
area.pos.x = area.size.w + 2;
|
|
|
|
area.size.w = 97;
|
|
|
|
PtSetArg(&args[n++], Pt_ARG_AREA, &area, 0);
|
|
|
|
PtSetArg(&args[n++], Pt_ARG_ANCHOR_FLAGS, ~0, Pt_RIGHT_ANCHORED_RIGHT|Pt_LEFT_ANCHORED_RIGHT| \
|
|
|
|
Pt_TOP_ANCHORED_BOTTOM);
|
|
|
|
info->progress = PtCreateWidget(PtProgress, info->window, n, args);
|
|
|
|
}
|
|
|
|
|
|
|
|
// mozilla widget
|
|
|
|
area.pos.y = 0;
|
|
|
|
area.pos.x = 0;
|
|
|
|
area.size.w = win_dim.w;
|
|
|
|
area.size.h = win_dim.h;
|
|
|
|
if ((window_flags & Pt_MOZ_FLAG_LOCATIONBARON) || (window_flags & Pt_MOZ_FLAG_TOOLBARON))
|
|
|
|
{
|
|
|
|
area.pos.y += 26;
|
|
|
|
area.size.h -= 26;
|
|
|
|
}
|
|
|
|
if (window_flags & Pt_MOZ_FLAG_STATUSBARON)
|
|
|
|
area.size.h -= 22;
|
2000-07-12 13:53:29 +00:00
|
|
|
|
|
|
|
n = 0;
|
|
|
|
PtSetArg(&args[n++], Pt_ARG_AREA, &area, 0);
|
2001-07-04 19:42:06 +00:00
|
|
|
PtSetArg(&args[n++], Pt_ARG_ANCHOR_FLAGS, ~0, Pt_RIGHT_ANCHORED_RIGHT | \
|
|
|
|
Pt_LEFT_ANCHORED_LEFT | Pt_TOP_ANCHORED_TOP | Pt_BOTTOM_ANCHORED_BOTTOM);
|
|
|
|
info->web = PtCreateWidget(PtMozilla, info->window, n, args);
|
|
|
|
PtAddCallback(info->web, Pt_CB_MOZ_PROGRESS, moz_progress_cb, NULL);
|
|
|
|
PtAddCallback(info->web, Pt_CB_MOZ_START, moz_start_cb, NULL);
|
|
|
|
PtAddCallback(info->web, Pt_CB_MOZ_COMPLETE, moz_complete_cb, NULL);
|
|
|
|
PtAddCallback(info->web, Pt_CB_MOZ_URL, moz_url_cb, NULL);
|
|
|
|
PtAddCallback(info->web, Pt_CB_MOZ_OPEN, moz_open_cb, NULL);
|
|
|
|
PtAddCallback(info->web, Pt_CB_MOZ_INFO, moz_info_cb, NULL);
|
|
|
|
PtAddCallback(info->web, Pt_CB_MOZ_NET_STATE, moz_net_state_change_cb, NULL);
|
|
|
|
PtAddCallback(info->web, Pt_CB_MOZ_AUTHENTICATE, moz_auth_cb, NULL);
|
|
|
|
PtAddCallback(info->web, Pt_CB_MOZ_DIALOG, moz_dialog_cb, NULL);
|
|
|
|
PtAddCallback(info->web, Pt_CB_MOZ_PROMPT, moz_prompt_cb, NULL);
|
|
|
|
PtAddCallback(info->web, Pt_CB_MOZ_NEW_WINDOW, moz_new_window_cb, NULL);
|
|
|
|
PtAddCallback(info->web, Pt_CB_MOZ_VISIBILITY, moz_visibility_cb, NULL);
|
|
|
|
PtAddCallback(info->web, Pt_CB_MOZ_DESTROY, moz_destroy_cb, NULL);
|
|
|
|
PtAddCallback(info->web, Pt_CB_MOZ_CONTEXT, moz_context_cb, NULL);
|
|
|
|
PtAddCallback(info->web, Pt_CB_MOZ_PRINT_STATUS, moz_print_status_cb, NULL);
|
|
|
|
|
|
|
|
window_count++;
|
|
|
|
|
|
|
|
return (info->window);
|
|
|
|
}
|
2000-07-12 13:53:29 +00:00
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
void set_pref(PtWidget_t *widget)
|
|
|
|
{
|
|
|
|
// see 'mozilla/modules/libpref/src/init/all.js' for a list of preferences
|
|
|
|
MozSetPreference(widget, Pt_MOZ_PREF_BOOL, "browser.underline_anchors", (void *)0);
|
|
|
|
MozSetPreference(widget, Pt_MOZ_PREF_COLOR, "browser.anchor_color", (void *)0xff0000);
|
|
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2000-07-12 13:53:29 +00:00
|
|
|
|
2000-10-12 16:27:52 +00:00
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
unsigned window_flags = ~0;
|
|
|
|
PtWidget_t *win;
|
|
|
|
struct window_info *i;
|
2000-07-12 13:53:29 +00:00
|
|
|
|
2001-07-04 19:42:06 +00:00
|
|
|
PtInit(NULL);
|
|
|
|
|
|
|
|
win = create_browser_window(window_flags);
|
|
|
|
PtGetResource(win, Pt_ARG_POINTER, &i, 0);
|
|
|
|
|
|
|
|
if (argc > 1)
|
|
|
|
{
|
|
|
|
// set some preferences
|
|
|
|
set_pref(i->web);
|
|
|
|
}
|
|
|
|
|
|
|
|
PtRealizeWidget(i->window);
|
|
|
|
PtSetResource(i->web, Pt_ARG_MOZ_GET_URL, "www.qnx.com", 0);
|
2000-07-12 13:53:29 +00:00
|
|
|
|
|
|
|
PtMainLoop();
|
|
|
|
}
|