fix bug where we were returning the js status string instead of the location. remove the toplevel window handling code for now. reverse the cur + max totals for progress updates since it makes more sense that way. fix signal marshallers to assume that int != int32. fix wrong marshaler for net_status and progress signals. change prototypes from GtkWidget * to GtkMozEmbed * since that's the Gtk way. make sure to actually pass the flags during a net_status signal.

This commit is contained in:
blizzard%redhat.com 2000-05-09 03:01:41 +00:00
Родитель 3dd758d1b9
Коммит 73c394b953
3 изменённых файлов: 46 добавлений и 151 удалений

Просмотреть файл

@ -196,8 +196,8 @@ NS_IMETHODIMP GtkMozEmbedChrome::GetLocation (char **retval)
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("GtkMozEmbedChrome::GetLocation\n")); PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("GtkMozEmbedChrome::GetLocation\n"));
NS_ENSURE_ARG_POINTER(retval); NS_ENSURE_ARG_POINTER(retval);
*retval = NULL; *retval = NULL;
if (mJSStatus) if (mLocation)
*retval = nsCRT::strdup(mJSStatus); *retval = nsCRT::strdup(mLocation);
return NS_OK; return NS_OK;
} }
@ -279,10 +279,10 @@ NS_IMETHODIMP GtkMozEmbedChrome::GetNewBrowser(PRUint32 chromeMask,
nsIWebBrowser **_retval) nsIWebBrowser **_retval)
{ {
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("GtkMozEmbedChrome::GetNewBrowser\n")); PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("GtkMozEmbedChrome::GetNewBrowser\n"));
NS_ENSURE_STATE(mNewBrowserCB);
if (mNewBrowserCB) if (mNewBrowserCB)
return mNewBrowserCB(chromeMask, _retval, mNewBrowserCBData); return mNewBrowserCB(chromeMask, _retval, mNewBrowserCBData);
return NS_ERROR_FAILURE; else
return NS_ERROR_NOT_IMPLEMENTED;
} }
NS_IMETHODIMP GtkMozEmbedChrome::FindNamedBrowserItem(const PRUnichar *aName, NS_IMETHODIMP GtkMozEmbedChrome::FindNamedBrowserItem(const PRUnichar *aName,
@ -392,8 +392,8 @@ NS_IMETHODIMP GtkMozEmbedChrome::OnProgressChange(nsIChannel *channel, PRInt32 c
PRInt32 maxTotalProgress) PRInt32 maxTotalProgress)
{ {
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("GtkMozEmbedChrome::OnProgressChange\n")); PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("GtkMozEmbedChrome::OnProgressChange\n"));
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("maxTotalProgress is %d and curTotalProgress is %d\n", PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("curTotalProgress is %d and maxTotalProgress is %d\n",
maxTotalProgress, curTotalProgress)); curTotalProgress, maxTotalProgress));
if (maxTotalProgress >= 0) if (maxTotalProgress >= 0)
{ {
PRUint32 percentage = (curTotalProgress * 100) / maxTotalProgress; PRUint32 percentage = (curTotalProgress * 100) / maxTotalProgress;
@ -406,7 +406,7 @@ NS_IMETHODIMP GtkMozEmbedChrome::OnProgressChange(nsIChannel *channel, PRInt32 c
// call our callback if it's been registered // call our callback if it's been registered
if (mProgressCB) if (mProgressCB)
mProgressCB(mProgressCBData, maxTotalProgress, curTotalProgress); mProgressCB(mProgressCBData, curTotalProgress, maxTotalProgress);
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }

Просмотреть файл

@ -95,14 +95,6 @@ gtk_moz_embed_handle_show(GtkWidget *widget, gpointer user_data);
static void static void
gtk_moz_embed_handle_event_queue(gpointer data, gint source, GdkInputCondition condition); gtk_moz_embed_handle_event_queue(gpointer data, gint source, GdkInputCondition condition);
/* call back to create a new toplevel window */
static nsresult
gtk_moz_embed_handle_new_browser(PRUint32 chromeMask, nsIWebBrowser **_retval, void *aData);
/* call back to track visibility changes */
static void
gtk_moz_embed_handle_toplevel_visibility_change(PRBool aVisibility, void *aData);
/* callbacks from various changes in the window */ /* callbacks from various changes in the window */
static void static void
gtk_moz_embed_handle_link_change(GtkMozEmbed *embed); gtk_moz_embed_handle_link_change(GtkMozEmbed *embed);
@ -117,10 +109,10 @@ static void
gtk_moz_embed_handle_title_change(GtkMozEmbed *embed); gtk_moz_embed_handle_title_change(GtkMozEmbed *embed);
static void static void
gtk_moz_embed_handle_progress(GtkMozEmbed *embed, gint32 maxprogress, gint32 curprogress); gtk_moz_embed_handle_progress(GtkMozEmbed *embed, gint32 curprogress, gint32 maxprogress);
static void static void
gtk_moz_embed_handle_net(GtkMozEmbed *embed, gint32 flags); gtk_moz_embed_handle_net(GtkMozEmbed *embed, gint flags);
static GtkBinClass *parent_class; static GtkBinClass *parent_class;
@ -244,15 +236,15 @@ gtk_moz_embed_class_init(GtkMozEmbedClass *klass)
GTK_RUN_FIRST, GTK_RUN_FIRST,
object_class->type, object_class->type,
GTK_SIGNAL_OFFSET(GtkMozEmbedClass, progress), GTK_SIGNAL_OFFSET(GtkMozEmbedClass, progress),
gtk_marshal_NONE__INT, gtk_marshal_NONE__INT_INT,
GTK_TYPE_NONE, 1, GTK_TYPE_INT); GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT);
moz_embed_signals[NET_STATUS] = moz_embed_signals[NET_STATUS] =
gtk_signal_new("net_status", gtk_signal_new("net_status",
GTK_RUN_FIRST, GTK_RUN_FIRST,
object_class->type, object_class->type,
GTK_SIGNAL_OFFSET(GtkMozEmbedClass, net_status), GTK_SIGNAL_OFFSET(GtkMozEmbedClass, net_status),
gtk_marshal_NONE__INT_INT, gtk_marshal_NONE__INT,
GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT); GTK_TYPE_NONE, 1, GTK_TYPE_INT);
moz_embed_signals[NET_START] = moz_embed_signals[NET_START] =
gtk_signal_new("net_start", gtk_signal_new("net_start",
GTK_RUN_FIRST, GTK_RUN_FIRST,
@ -308,9 +300,9 @@ gtk_moz_embed_init(GtkMozEmbed *embed)
embed); embed);
embed_private->embed->SetTitleChangeCallback((generic_cb_with_data)gtk_moz_embed_handle_title_change, embed_private->embed->SetTitleChangeCallback((generic_cb_with_data)gtk_moz_embed_handle_title_change,
embed); embed);
embed_private->embed->SetProgressCallback((void (*)(void *, gint32, gint32))gtk_moz_embed_handle_progress, embed_private->embed->SetProgressCallback((void (*)(void *, gint, gint))gtk_moz_embed_handle_progress,
embed); embed);
embed_private->embed->SetNetCallback((void (*)(void *, gint32))gtk_moz_embed_handle_net, embed_private->embed->SetNetCallback((void (*)(void *, gint))gtk_moz_embed_handle_net,
embed); embed);
} }
@ -321,20 +313,17 @@ gtk_moz_embed_new(void)
} }
void void
gtk_moz_embed_load_url(GtkWidget *widget, const char *url) gtk_moz_embed_load_url(GtkMozEmbed *embed, const char *url)
{ {
GtkMozEmbed *embed;
GtkMozEmbedPrivate *embed_private; GtkMozEmbedPrivate *embed_private;
g_return_if_fail (widget != NULL); g_return_if_fail (embed != NULL);
g_return_if_fail (GTK_IS_MOZ_EMBED(widget)); g_return_if_fail (GTK_IS_MOZ_EMBED(embed));
embed = GTK_MOZ_EMBED(widget);
embed_private = (GtkMozEmbedPrivate *)embed->data; embed_private = (GtkMozEmbedPrivate *)embed->data;
// If the widget aint realized, save the url for later // If the widget aint realized, save the url for later
if (!GTK_WIDGET_REALIZED(widget)) if (!GTK_WIDGET_REALIZED(embed))
{ {
embed_private->mInitialURL = url; embed_private->mInitialURL = url;
return; return;
@ -348,15 +337,12 @@ gtk_moz_embed_load_url(GtkWidget *widget, const char *url)
} }
void void
gtk_moz_embed_stop_load (GtkWidget *widget) gtk_moz_embed_stop_load (GtkMozEmbed *embed)
{ {
GtkMozEmbed *embed;
GtkMozEmbedPrivate *embed_private; GtkMozEmbedPrivate *embed_private;
g_return_if_fail (widget != NULL); g_return_if_fail (embed != NULL);
g_return_if_fail (GTK_IS_MOZ_EMBED(widget)); g_return_if_fail (GTK_IS_MOZ_EMBED(embed));
embed = GTK_MOZ_EMBED(widget);
embed_private = (GtkMozEmbedPrivate *)embed->data; embed_private = (GtkMozEmbedPrivate *)embed->data;
@ -366,16 +352,13 @@ gtk_moz_embed_stop_load (GtkWidget *widget)
} }
char * char *
gtk_moz_embed_get_link_message (GtkWidget *widget) gtk_moz_embed_get_link_message (GtkMozEmbed *embed)
{ {
GtkMozEmbed *embed;
GtkMozEmbedPrivate *embed_private; GtkMozEmbedPrivate *embed_private;
char *retval = NULL; char *retval = NULL;
g_return_val_if_fail ((widget != NULL), NULL); g_return_val_if_fail ((embed != NULL), NULL);
g_return_val_if_fail ((GTK_IS_MOZ_EMBED(widget)), NULL); g_return_val_if_fail ((GTK_IS_MOZ_EMBED(embed)), NULL);
embed = GTK_MOZ_EMBED(widget);
embed_private = (GtkMozEmbedPrivate *)embed->data; embed_private = (GtkMozEmbedPrivate *)embed->data;
@ -385,16 +368,13 @@ gtk_moz_embed_get_link_message (GtkWidget *widget)
} }
char * char *
gtk_moz_embed_get_js_status (GtkWidget *widget) gtk_moz_embed_get_js_status (GtkMozEmbed *embed)
{ {
GtkMozEmbed *embed;
GtkMozEmbedPrivate *embed_private; GtkMozEmbedPrivate *embed_private;
char *retval = NULL; char *retval = NULL;
g_return_val_if_fail ((widget != NULL), NULL); g_return_val_if_fail ((embed != NULL), NULL);
g_return_val_if_fail ((GTK_IS_MOZ_EMBED(widget)), NULL); g_return_val_if_fail ((GTK_IS_MOZ_EMBED(embed)), NULL);
embed = GTK_MOZ_EMBED(widget);
embed_private = (GtkMozEmbedPrivate *)embed->data; embed_private = (GtkMozEmbedPrivate *)embed->data;
@ -404,16 +384,13 @@ gtk_moz_embed_get_js_status (GtkWidget *widget)
} }
char * char *
gtk_moz_embed_get_title (GtkWidget *widget) gtk_moz_embed_get_title (GtkMozEmbed *embed)
{ {
GtkMozEmbed *embed;
GtkMozEmbedPrivate *embed_private; GtkMozEmbedPrivate *embed_private;
char *retval = NULL; char *retval = NULL;
g_return_val_if_fail ((widget != NULL), NULL); g_return_val_if_fail ((embed != NULL), NULL);
g_return_val_if_fail ((GTK_IS_MOZ_EMBED(widget)), NULL); g_return_val_if_fail ((GTK_IS_MOZ_EMBED(embed)), NULL);
embed = GTK_MOZ_EMBED(widget);
embed_private = (GtkMozEmbedPrivate *)embed->data; embed_private = (GtkMozEmbedPrivate *)embed->data;
@ -423,16 +400,13 @@ gtk_moz_embed_get_title (GtkWidget *widget)
} }
char * char *
gtk_moz_embed_get_location (GtkWidget *widget) gtk_moz_embed_get_location (GtkMozEmbed *embed)
{ {
GtkMozEmbed *embed;
GtkMozEmbedPrivate *embed_private; GtkMozEmbedPrivate *embed_private;
char *retval = NULL; char *retval = NULL;
g_return_val_if_fail ((widget != NULL), NULL); g_return_val_if_fail ((embed != NULL), NULL);
g_return_val_if_fail ((GTK_IS_MOZ_EMBED(widget)), NULL); g_return_val_if_fail ((GTK_IS_MOZ_EMBED(embed)), NULL);
embed = GTK_MOZ_EMBED(widget);
embed_private = (GtkMozEmbedPrivate *)embed->data; embed_private = (GtkMozEmbedPrivate *)embed->data;
@ -494,8 +468,6 @@ gtk_moz_embed_realize(GtkWidget *widget)
{ {
webBrowserBaseWindow->SetVisibility(PR_TRUE); webBrowserBaseWindow->SetVisibility(PR_TRUE);
} }
// set our callback for creating new browser windows
embed_private->embed->SetNewBrowserCallback(gtk_moz_embed_handle_new_browser, widget);
// set our webBrowser object as the content listener object // set our webBrowser object as the content listener object
nsCOMPtr<nsIURIContentListener> uriListener; nsCOMPtr<nsIURIContentListener> uriListener;
uriListener = do_QueryInterface(embed_private->embed); uriListener = do_QueryInterface(embed_private->embed);
@ -506,7 +478,7 @@ gtk_moz_embed_realize(GtkWidget *widget)
if (embed_private->mInitialURL.Length() > 0) if (embed_private->mInitialURL.Length() > 0)
{ {
const char * foo = (const char *) embed_private->mInitialURL; const char * foo = (const char *) embed_private->mInitialURL;
gtk_moz_embed_load_url (widget, foo); gtk_moz_embed_load_url (GTK_MOZ_EMBED(widget), foo);
embed_private->mInitialURL = ""; embed_private->mInitialURL = "";
} }
} }
@ -608,83 +580,6 @@ gtk_moz_embed_handle_event_queue(gpointer data, gint source, GdkInputCondition c
eventQueue->ProcessPendingEvents(); eventQueue->ProcessPendingEvents();
} }
static nsresult
gtk_moz_embed_handle_new_browser(PRUint32 chromeMask, nsIWebBrowser **_retval, void *aData)
{
GtkMozEmbed *embed;
GtkMozEmbedPrivate *embed_private;
g_print("gtk_moz_embed_handle_new_browser\n");
g_return_val_if_fail ((aData != NULL), NS_ERROR_INVALID_ARG);
g_return_val_if_fail ((GTK_IS_MOZ_EMBED(aData)), NS_ERROR_INVALID_ARG);
embed = GTK_MOZ_EMBED(aData);
embed_private = (GtkMozEmbedPrivate *)embed->data;
// XXX what we need to do here is have a signal or something that
// allows us to allow user defined functions to create the toplevel
// window
GtkWidget *newTopLevel = NULL;
GtkWidget *newMozEmbed = NULL;
GtkMozEmbed *newEmbed = NULL;
GtkMozEmbedPrivate *newEmbedPrivate = NULL;
newTopLevel = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_realize(newTopLevel);
newMozEmbed = gtk_moz_embed_new();
// add this new child as a container of the toplevel window before
// we realize it
gtk_container_add(GTK_CONTAINER(newTopLevel), newMozEmbed);
// realize it to trigger the creation of all of the mozilla objects
gtk_widget_realize(newMozEmbed);
// get our hands on the embed internals
newEmbed = GTK_MOZ_EMBED(newMozEmbed);
newEmbedPrivate = (GtkMozEmbedPrivate *)newEmbed->data;
// track visibility requests
newEmbedPrivate->embed->SetVisibilityCallback(gtk_moz_embed_handle_toplevel_visibility_change,
newMozEmbed);
*_retval = newEmbedPrivate->webBrowser;
g_print("returning new toplevel web browser as %p\n", *_retval);
NS_ADDREF(*_retval);
return NS_OK;
}
static void
gtk_moz_embed_handle_toplevel_visibility_change(PRBool aVisibility, void *aData)
{
GtkMozEmbed *embed;
GtkMozEmbedPrivate *embed_private;
GtkWidget *topLevelWidget;
g_print("gtk_moz_embed_handle_toplevel_visibility_change\n");
g_return_if_fail (aData != NULL);
g_return_if_fail (GTK_IS_MOZ_EMBED(aData));
embed = GTK_MOZ_EMBED(aData);
embed_private = (GtkMozEmbedPrivate *)embed->data;
// the ->parent is always going to be the GtkWindow
if (aVisibility)
{
topLevelWidget = gtk_widget_get_toplevel(GTK_WIDGET(embed));
gtk_widget_show_all(topLevelWidget);
//gtk_widget_show(GTK_WIDGET(embed));
//gtk_widget_show(GTK_WIDGET(embed)->parent);
}
else
{
gtk_widget_hide(GTK_WIDGET(embed)->parent);
gtk_widget_hide(GTK_WIDGET(embed));
}
}
static void static void
gtk_moz_embed_handle_link_change(GtkMozEmbed *embed) gtk_moz_embed_handle_link_change(GtkMozEmbed *embed)
{ {
@ -718,11 +613,11 @@ gtk_moz_embed_handle_title_change(GtkMozEmbed *embed)
} }
static void static void
gtk_moz_embed_handle_progress(GtkMozEmbed *embed, gint32 maxprogress, gint32 curprogress) gtk_moz_embed_handle_progress(GtkMozEmbed *embed, gint32 curprogress, gint32 maxprogress)
{ {
g_return_if_fail (GTK_IS_MOZ_EMBED(embed)); g_return_if_fail (GTK_IS_MOZ_EMBED(embed));
gtk_signal_emit(GTK_OBJECT(embed), moz_embed_signals[PROGRESS], maxprogress, curprogress); gtk_signal_emit(GTK_OBJECT(embed), moz_embed_signals[PROGRESS], curprogress, maxprogress);
} }
static void static void
@ -734,7 +629,7 @@ gtk_moz_embed_handle_net(GtkMozEmbed *embed, gint32 flags)
if (flags & gtk_moz_embed_flag_win_start) if (flags & gtk_moz_embed_flag_win_start)
gtk_signal_emit(GTK_OBJECT(embed), moz_embed_signals[NET_START]); gtk_signal_emit(GTK_OBJECT(embed), moz_embed_signals[NET_START]);
// for people who know what they are doing // for people who know what they are doing
gtk_signal_emit(GTK_OBJECT(embed), moz_embed_signals[NET_STATUS]); gtk_signal_emit(GTK_OBJECT(embed), moz_embed_signals[NET_STATUS], flags);
// and for stop, too // and for stop, too
if (flags & gtk_moz_embed_flag_win_stop) if (flags & gtk_moz_embed_flag_win_stop)
gtk_signal_emit(GTK_OBJECT(embed), moz_embed_signals[NET_STOP]); gtk_signal_emit(GTK_OBJECT(embed), moz_embed_signals[NET_STOP]);

Просмотреть файл

@ -52,20 +52,20 @@ struct _GtkMozEmbedClass
void (* js_status) (GtkMozEmbed *embed); void (* js_status) (GtkMozEmbed *embed);
void (* location) (GtkMozEmbed *embed); void (* location) (GtkMozEmbed *embed);
void (* title) (GtkMozEmbed *embed); void (* title) (GtkMozEmbed *embed);
void (* progress) (GtkMozEmbed *embed, gint32 maxprogress, gint32 curprogress); void (* progress) (GtkMozEmbed *embed, gint maxprogress, gint curprogress);
void (* net_status) (GtkMozEmbed *embed, gint32 status); void (* net_status) (GtkMozEmbed *embed, gint status);
void (* net_start) (GtkMozEmbed *embed); void (* net_start) (GtkMozEmbed *embed);
void (* net_stop) (GtkMozEmbed *embed); void (* net_stop) (GtkMozEmbed *embed);
}; };
extern GtkType gtk_moz_embed_get_type (void); extern GtkType gtk_moz_embed_get_type (void);
extern GtkWidget *gtk_moz_embed_new (void); extern GtkWidget *gtk_moz_embed_new (void);
extern void gtk_moz_embed_load_url (GtkWidget *widget, const char *url); extern void gtk_moz_embed_load_url (GtkMozEmbed *embed, const char *url);
extern void gtk_moz_embed_stop_load (GtkWidget *widget); extern void gtk_moz_embed_stop_load (GtkMozEmbed *embed);
extern char *gtk_moz_embed_get_link_message (GtkWidget *widget); extern char *gtk_moz_embed_get_link_message (GtkMozEmbed *embed);
extern char *gtk_moz_embed_get_js_status (GtkWidget *widget); extern char *gtk_moz_embed_get_js_status (GtkMozEmbed *embed);
extern char *gtk_moz_embed_get_title (GtkWidget *widget); extern char *gtk_moz_embed_get_title (GtkMozEmbed *embed);
extern char *gtk_moz_embed_get_location (GtkWidget *widget); extern char *gtk_moz_embed_get_location (GtkMozEmbed *embed);
/* These are straight out of nsIWebProgress.h */ /* These are straight out of nsIWebProgress.h */