示例#1
0
static gboolean open_url( GtkXPart *part, const char * url )
{
    g_message( "open_url %s", url );
    openUrlRequested = FALSE;
    gtk_moz_embed_load_url( P->mozilla, url );
    return TRUE;
}
示例#2
0
static void
impl_load_url (GaleonEmbed *embed, 
               const char *url)
{
	char *clean_url;

        clean_url = gul_string_remove_outside_whitespace (url);

        gtk_moz_embed_load_url (GTK_MOZ_EMBED(embed),
                                clean_url);

	/* LOAD HACK: If we haven't loaded a url yet, remember this one, 
	 * and flag that we are trying to load this url */
	MozillaEmbed *membed = MOZILLA_EMBED (embed);
	if (!membed->priv->loaded_url)
	{
		g_free (membed->priv->loading_url);
		membed->priv->loading_url = clean_url;

		/* Fake a "location" signal, so that the layer above picks up
		 * this url, and doesn't think there is no current url */
		g_signal_emit_by_name (membed, "ge_location");
		return;
	}

	g_free (clean_url);

	return;
}
示例#3
0
void
url_activate_cb    (GtkEditable *widget, TestGtkBrowser *browser)
{
    gchar *text = gtk_editable_get_chars(widget, 0, -1);
    g_print("loading url %s\n", text);
    gtk_moz_embed_load_url(GTK_MOZ_EMBED(browser->mozEmbed), text);
    g_free(text);
}
示例#4
0
void minimo_load_url(gchar *url, MinimoBrowser *browser)
{
  g_return_if_fail(browser->mozEmbed != NULL);
  g_return_if_fail(url != NULL);
  
  gtk_moz_embed_load_url(GTK_MOZ_EMBED(browser->mozEmbed), url);
  
  return;
}
示例#5
0
int
main(int argc, char **argv)
{
#ifdef NS_TRACE_MALLOC
    argc = NS_TraceMallocStartupArgs(argc, argv);
#endif

    gtk_set_locale();
    gtk_init(&argc, &argv);

#ifdef MOZ_JPROF
    setupProfilingStuff();
#endif

    char *home_path;
    char *full_path;
    home_path = PR_GetEnv("HOME");
    if (!home_path) {
        fprintf(stderr, "Failed to get HOME\n");
        exit(1);
    }

    full_path = g_strdup_printf("%s/%s", home_path, ".TestGtkEmbed");

    gtk_moz_embed_set_profile_path(full_path, "TestGtkEmbed");

    TestGtkBrowser *browser = new_gtk_browser(GTK_MOZ_EMBED_FLAG_DEFAULTCHROME);

    // set our minimum size
    gtk_widget_set_usize(browser->mozEmbed, 400, 400);

    set_browser_visibility(browser, TRUE);

    if (argc > 1)
        gtk_moz_embed_load_url(GTK_MOZ_EMBED(browser->mozEmbed), argv[1]);

    // get the singleton object and hook up to its new window callback
    // so we can create orphaned windows.

    GtkMozEmbedSingle *single;

    single = gtk_moz_embed_single_get();
    if (!single) {
        fprintf(stderr, "Failed to get singleton embed object!\n");
        exit(1);
    }

    gtk_signal_connect(GTK_OBJECT(single), "new_window_orphan",
                       GTK_SIGNAL_FUNC(new_window_orphan_cb), NULL);

    gtk_main();
}
/// Renders the given URL.
bool MozillaRenderer::renderUrl(const string &url)
{
	if (m_htmlWidget != NULL)
	{
#ifdef DEBUG
		cout << "MozillaRenderer::renderUrl: url " << url << endl;
#endif
		gtk_moz_embed_load_url(GTK_MOZ_EMBED(m_htmlWidget), url.c_str());
		m_rendering = true;
	}

	return m_rendering;
}
示例#7
0
int
main (int argc, char **argv)
{
	gtk_init (&argc, &argv);
	runtime_init (RUNTIME_INIT_BROWSER);

	window = GTK_WINDOW (gtk_window_new (GTK_WINDOW_TOPLEVEL));

	char xpcom_lib_path [PATH_MAX];
	char* xpcom_dir_path;

	GRE_GetGREPathWithProperties (&gre_version, 1, nsnull, 0, xpcom_lib_path, sizeof (xpcom_lib_path));
	xpcom_dir_path = g_path_get_dirname (xpcom_lib_path);

	gtk_moz_embed_set_path (xpcom_dir_path);
	g_free (xpcom_dir_path);

	GtkWidget *moz_embed = gtk_moz_embed_new();
	gtk_container_add (GTK_CONTAINER (window), moz_embed);

	gtk_widget_set_usize (moz_embed, 416, 416);

	char *current_directory = g_get_current_dir ();
	char *html_path = g_strdup_printf ("file://%s/test.html", current_directory);
	gtk_moz_embed_load_url (GTK_MOZ_EMBED (moz_embed), html_path);

	g_free (current_directory);
	g_free (html_path);

	gtk_widget_show_all (moz_embed);
	gtk_widget_show_all (GTK_WIDGET (window));
	g_timeout_add (500, setup, NULL);

	runtime_flags_set_manual_timesource (TRUE);
	runtime_flags_set_use_shapecache (FALSE);
	runtime_flags_set_show_fps (FALSE);
	
	gtk_main ();

	return 0;
}
static GtkWidget *createView(GnomeMDIChild *child,
        gpointer data)
{
#ifdef USE_MOZILLA_TEST
    GtkWidget *browser = gtk_moz_embed_new();
#else
#ifndef SAMPLE_PIXMAP
    GtkWidget *browser = gtk_label_new("lynx 0.01a");
#else
    /* Another example -- */
    GtkWidget *browser =
      gnome_pixmap_new_from_file("/usr/share/pixmaps/emacs.png");
#endif /* SAMPLE_PIXMAP */
#endif /* USE_MOZILLA_TEST */

    GtkWidget *notebook = gtk_notebook_new();
    char str[80];

    sprintf(str,"View of the\n%s widget",(gchar *)data);

#ifdef USE_MOZILLA_TEST
    gtk_moz_embed_load_url(GTK_MOZ_EMBED(browser), "http://www.mozilla.org");
#endif /* USE_MOZILLA_TEST */

#ifndef SIMPLER_TEST
    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), gtk_label_new(str),
			     gtk_label_new("Label"));
    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), browser,
			     gtk_label_new("Mozilla"));
    gtk_widget_show_all(notebook);
    return (notebook);
#else
    gtk_widget_show(browser);
    return (browser);
#endif /* SIMPLER_TEST */
}
int main(int argc, char *argv[])
{
	GtkWidget *window;
	GtkWidget *label;
	GtkWidget *mozembed;
	GtkWidget *container;
	char *url;

	gtk_init(&argc, &argv);
	
        static const GREVersionRange greVersion = {
                "1.9a", PR_TRUE,
                "2", PR_TRUE
        };

        char xpcomPath[PATH_MAX];

        nsresult rv =
                GRE_GetGREPathWithProperties(&greVersion, 1, nsnull, 0,
                                             xpcomPath, sizeof(xpcomPath));
        if (NS_FAILED(rv)) {
                fprintf(stderr, "Couldn't find a compatible GRE.\n");
                return 1;
        }

        rv = XPCOMGlueStartup(xpcomPath);
        if (NS_FAILED(rv)) {
                fprintf(stderr, "Couldn't start XPCOM.");
                return 1;
        }

        rv = GTKEmbedGlueStartup();
        if (NS_FAILED(rv)) {
                fprintf(stderr, "Couldn't find GTKMozEmbed symbols.");
                return 1;
        }

        char *lastSlash = strrchr(xpcomPath, '/');
        if (lastSlash)
                *lastSlash = '\0';

        gtk_moz_embed_set_path(xpcomPath);

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	
	container = gtk_notebook_new();
	mozembed = gtk_moz_embed_new();
	label = gtk_label_new("Can you see this message?\n"
			      "Once you switch to mozembed page " 
			      "you never see this message.");

	g_signal_connect(GTK_OBJECT(mozembed), "destroy",
	                 G_CALLBACK(gtk_main_quit),
NULL);

	gtk_container_add(GTK_CONTAINER(window), container);

	gtk_notebook_append_page(GTK_NOTEBOOK(container),
			label,
			gtk_label_new("gtk label"));

	gtk_notebook_append_page(GTK_NOTEBOOK(container),
			mozembed,
			gtk_label_new("mozembed"));




	gtk_widget_set_size_request(window, 400, 300);
	gtk_widget_show(mozembed);
	gtk_widget_show(label);
	gtk_widget_show_all(window);

	url = (argc > 1) ? argv[1] : (char *)"localhost";
	gtk_moz_embed_load_url(GTK_MOZ_EMBED(mozembed), url);

	gtk_main();
	
	return 0;
}
示例#10
0
int WebBrowserObject::BrowserOpen(void)
{
    Lock();
    if (!area.w) {
        area.w = systemObject->configGetInt("video_width", systemObject->GetScreenWidth());
    }
    if (!area.h) {
        area.h = systemObject->configGetInt("video_height", systemObject->GetScreenHeight());
    }
    if (!toplevel) {
        toplevel = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_widget_realize(toplevel);
        gdk_window_set_decorations(toplevel->window, (GdkWMDecoration)0);
        toplevelVBox = gtk_vbox_new(FALSE, 0);
        gtk_container_add(GTK_CONTAINER(toplevel), toplevelVBox);

        mozilla = gtk_moz_embed_new();
        gtk_moz_embed_set_chrome_mask(GTK_MOZ_EMBED(mozilla), GTK_MOZ_EMBED_FLAG_ALLCHROME);

        toolbarHBox = gtk_hbox_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(toplevelVBox), toolbarHBox, FALSE, FALSE, 0);
        toolbar = gtk_toolbar_new();
        g_object_ref(toolbar);
        gtk_toolbar_set_orientation(GTK_TOOLBAR(toolbar), GTK_ORIENTATION_HORIZONTAL);
        gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH);
        if (toolbar_flag) {
            gtk_box_pack_start(GTK_BOX(toolbarHBox), toolbar, FALSE, FALSE, 0);
        }
        backButton = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "Back", "Go Back", "Go Back", 0, GTK_SIGNAL_FUNC(back_clicked_cb), this);
        stopButton = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "Stop", "Stop", "Stop", 0, GTK_SIGNAL_FUNC(stop_clicked_cb), this);
        forwardButton = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "Forward", "Forward", "Forward", 0, GTK_SIGNAL_FUNC(forward_clicked_cb), this);
        reloadButton = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "Reload", "Reload", "Reload", 0, GTK_SIGNAL_FUNC(reload_clicked_cb), this);
        closeButton = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "Close", "Close window", "Close window", 0, GTK_SIGNAL_FUNC(close_clicked_cb), this);
        urlEntry = gtk_entry_new();
        g_object_ref(urlEntry);
        if (toolbar_flag) {
            gtk_box_pack_start(GTK_BOX(toolbarHBox), urlEntry, TRUE, TRUE, 0);
        }
        gtk_box_pack_start(GTK_BOX(toplevelVBox), mozilla, TRUE, TRUE, 0);
        progressAreaHBox = gtk_hbox_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(toplevelVBox), progressAreaHBox, FALSE, FALSE, 0);
        progressBar = gtk_progress_bar_new();
        gtk_box_pack_start(GTK_BOX(progressAreaHBox), progressBar, FALSE, FALSE, 0);
        statusAlign = gtk_alignment_new(0, 0, 1, 1);
        gtk_widget_set_usize(statusAlign, 1, -1);
        statusBar = gtk_statusbar_new();
        gtk_statusbar_set_has_resize_grip(GTK_STATUSBAR(statusBar), 0);
        gtk_container_add(GTK_CONTAINER(statusAlign), statusBar);
        gtk_box_pack_start(GTK_BOX(progressAreaHBox), statusAlign, TRUE, TRUE, 0);

        gtk_widget_set_sensitive(closeButton, TRUE);
        gtk_widget_set_sensitive(backButton, FALSE);
        gtk_widget_set_sensitive(stopButton, FALSE);
        gtk_widget_set_sensitive(forwardButton, FALSE);
        gtk_widget_set_sensitive(reloadButton, FALSE);

        gtk_signal_connect(GTK_OBJECT(urlEntry), "activate", GTK_SIGNAL_FUNC(url_activate_cb), this);
        
        gtk_signal_connect(GTK_OBJECT(toplevel), "delete_event", GTK_SIGNAL_FUNC(delete_cb), this);
        gtk_signal_connect(GTK_OBJECT(mozilla), "destroy", GTK_SIGNAL_FUNC(destroy_cb), this);
        gtk_signal_connect(GTK_OBJECT(mozilla), "destroy_browser", GTK_SIGNAL_FUNC(destroy_cb), this);
        gtk_signal_connect(GTK_OBJECT(mozilla), "title", GTK_SIGNAL_FUNC(title_changed_cb), this);
        gtk_signal_connect(GTK_OBJECT(mozilla), "new_window", GTK_SIGNAL_FUNC(new_window_cb), this);
        gtk_signal_connect(GTK_OBJECT(mozilla), "visibility", GTK_SIGNAL_FUNC(visibility_cb), this);
        gtk_signal_connect(GTK_OBJECT(mozilla), "size_to", GTK_SIGNAL_FUNC(size_to_cb), this);
        gtk_signal_connect(GTK_OBJECT(mozilla), "location", GTK_SIGNAL_FUNC(location_cb), this);
        gtk_signal_connect(GTK_OBJECT(mozilla), "net_start", GTK_SIGNAL_FUNC(net_start_cb), this);
        gtk_signal_connect(GTK_OBJECT(mozilla), "net_stop", GTK_SIGNAL_FUNC(net_stop_cb), this);
        gtk_signal_connect(GTK_OBJECT(mozilla), "net_state",  GTK_SIGNAL_FUNC(net_state_cb), this);
        gtk_signal_connect(GTK_OBJECT(mozilla), "progress", GTK_SIGNAL_FUNC(progress_cb), this);
        gtk_signal_connect(GTK_OBJECT(mozilla), "link_message", GTK_SIGNAL_FUNC(link_message_cb), this);
        gtk_signal_connect(GTK_OBJECT(mozilla), "js_status", GTK_SIGNAL_FUNC(js_status_cb), this);
        gtk_signal_connect(GTK_OBJECT(mozilla), "open_uri", GTK_SIGNAL_FUNC(open_uri_cb), this);
        gtk_signal_connect(GTK_OBJECT(mozilla), "dom_key_down", GTK_SIGNAL_FUNC(dom_key_down_cb), this);
        gtk_signal_connect(GTK_OBJECT(mozilla), "dom_key_up", GTK_SIGNAL_FUNC(dom_key_up_cb), this);
        gtk_signal_connect(GTK_OBJECT(mozilla), "dom_mouse_down", GTK_SIGNAL_FUNC(dom_mouse_down_cb), this);
        gtk_signal_connect(GTK_OBJECT(mozilla), "dom_mouse_up", GTK_SIGNAL_FUNC(dom_mouse_up_cb), this);
        gtk_signal_connect(GTK_OBJECT(mozilla), "dom_key_press", GTK_SIGNAL_FUNC(dom_key_press_cb), this);
        gtk_signal_connect(GTK_OBJECT(mozilla), "dom_mouse_click", GTK_SIGNAL_FUNC(dom_mouse_click_cb), this);
        gtk_signal_connect(GTK_OBJECT(mozilla), "dom_mouse_dbl_click", GTK_SIGNAL_FUNC(dom_mouse_dbl_click_cb), this);
        gtk_signal_connect(GTK_OBJECT(mozilla), "dom_mouse_over", GTK_SIGNAL_FUNC(dom_mouse_over_cb), this);
        gtk_signal_connect(GTK_OBJECT(mozilla), "dom_mouse_out", GTK_SIGNAL_FUNC(dom_mouse_out_cb), this);
    }
    Unlock();
    SetPosition(area.x, area.y, area.w, area.h);
    SetVisible(1);
    if (location) {
        gtk_moz_embed_load_url(GTK_MOZ_EMBED(mozilla), location);
    }
    systemObject->RegisterExternalEventHandler(this);
    return 0;
}
示例#11
0
static void url_activate_cb (GtkEditable *widget, WebBrowserObject *browser)
{
    gchar *text = gtk_editable_get_chars(widget, 0, -1);
    gtk_moz_embed_load_url(GTK_MOZ_EMBED(browser->mozilla), text);
    g_free(text);
}
示例#12
0
void 
HandleSocketMessage(gpointer data, gpointer user_data)
{
    int instance, type;
    char mMsgBuf[1024];
    char *msg = (char *)data;

    int i = sscanf(msg, "%d,%d,%s", &instance, &type, mMsgBuf);

    NS_ASSERTION(i >= 2, "Wrong message format\n");

    // In case that the last message string argument contains spaces, sscanf 
    // returns before the first space. Below line returns the complete message
    // string.
    char* mMsgString = (char*)strchr(msg, ',');
    mMsgString++;
    mMsgString = (char*)strchr(mMsgString, ',');
    mMsgString++;

    GtkBrowser *pBrowser;
    switch (type) {
    case JEVENT_INIT:
        break;
    case JEVENT_CREATEWINDOW:
        {
            // only create new browser window when the instance does not exist
            if (instance < gBrowserArray.GetSize() && gBrowserArray[instance] != NULL)
                break;
            if (i != 3)
                break;
            int javaXId = atoi(mMsgString);
            NS_ASSERTION(javaXId, "Invalid X window handle\n");
            pBrowser = g_new0(GtkBrowser, 1);
            pBrowser->topLevelWindow = gtk_plug_new(javaXId);
            pBrowser->mozEmbed = gtk_moz_embed_new();
            if (pBrowser->mozEmbed) {
                gtk_container_add(GTK_CONTAINER(pBrowser->topLevelWindow), pBrowser->mozEmbed);
                install_mozembed_cb(pBrowser);
                gtk_moz_embed_set_chrome_mask(GTK_MOZ_EMBED(pBrowser->mozEmbed),
                    GTK_MOZ_EMBED_FLAG_DEFAULTCHROME);
                gtk_widget_realize(pBrowser->topLevelWindow);
                gtk_widget_show_all(pBrowser->topLevelWindow);
                pBrowser->id = instance;
                gBrowserArray.SetAtGrow(instance, pBrowser);
                SendSocketMessage(instance, CEVENT_INIT_WINDOW_SUCC);
            }

            gtk_signal_connect(GTK_OBJECT(pBrowser->topLevelWindow), 
                  "set-focus", GTK_SIGNAL_FUNC(set_focus_cb), pBrowser);

        }
        break;
    case JEVENT_DESTROYWINDOW:
        pBrowser = (GtkBrowser *)gBrowserArray[instance];
        if(pBrowser != NULL){
            gtk_widget_destroy(pBrowser->mozEmbed);
            gtk_object_destroy((GtkObject *)pBrowser->topLevelWindow);
            gBrowserArray.SetAt(instance, NULL);
        }
        SendSocketMessage(instance, CEVENT_DISTORYWINDOW_SUCC);
        break;
    case JEVENT_SHUTDOWN:
        gtk_main_quit();
        break;
    case JEVENT_SET_BOUNDS:
        {
            NS_ASSERTION(i == 3, "Wrong message format\n");
            int x, y, w, h;
            i = sscanf(mMsgString, "%d,%d,%d,%d", &x, &y, &w, &h);
            if (i == 4) {
                pBrowser = (GtkBrowser *)gBrowserArray[instance];
                NS_ASSERTION(pBrowser, "Can't get native browser instance\n");
                gtk_widget_set_usize(pBrowser->topLevelWindow, w, h);
            }
        }
        break;
    case JEVENT_NAVIGATE:
        NS_ASSERTION(i == 3, "Wrong message format\n");
        pBrowser = (GtkBrowser *)gBrowserArray[instance];
        NS_ASSERTION(pBrowser, "Can't get native browser instance\n");
        gtk_moz_embed_load_url(GTK_MOZ_EMBED(pBrowser->mozEmbed), mMsgString);
        break;
    case JEVENT_NAVIGATE_POST:
        NS_ASSERTION(i == 3, "Wrong message format\n");
        strncpy(gCachedURL, mMsgString, sizeof(gCachedURL));
        break;
    case JEVENT_NAVIGATE_POSTDATA:
        NS_ASSERTION(i == 3, "Wrong message format\n");
        pBrowser = (GtkBrowser *)gBrowserArray[instance];
        OpenURL(pBrowser, gCachedURL, mMsgString, POST_HEADER);
        break;
    case JEVENT_GOBACK:
        pBrowser = (GtkBrowser *)gBrowserArray[instance];
        NS_ASSERTION(pBrowser, "Can't get native browser instance\n");
        gtk_moz_embed_go_back(GTK_MOZ_EMBED(pBrowser->mozEmbed));
        break;
    case JEVENT_GOFORWARD:
        pBrowser = (GtkBrowser *)gBrowserArray[instance];
        NS_ASSERTION(pBrowser, "Can't get native browser instance\n");
        gtk_moz_embed_go_forward(GTK_MOZ_EMBED(pBrowser->mozEmbed));
        break;
    case JEVENT_REFRESH:
        pBrowser = (GtkBrowser *)gBrowserArray[instance];
        NS_ASSERTION(pBrowser, "Can't get native browser instance\n");
        gtk_moz_embed_reload(GTK_MOZ_EMBED(pBrowser->mozEmbed), GTK_MOZ_EMBED_FLAG_RELOADNORMAL);
        break;
    case JEVENT_STOP:
        pBrowser = (GtkBrowser *)gBrowserArray[instance];
        NS_ASSERTION(pBrowser, "Can't get native browser instance\n");
        gtk_moz_embed_stop_load(GTK_MOZ_EMBED(pBrowser->mozEmbed));
        break;
    case JEVENT_GETURL:
        {
            pBrowser = (GtkBrowser *)gBrowserArray[instance];
            NS_ASSERTION(pBrowser, "Can't get native browser instance\n");
            nsCOMPtr<nsIWebBrowser> webBrowser;
            gtk_moz_embed_get_nsIWebBrowser(GTK_MOZ_EMBED(pBrowser->mozEmbed), getter_AddRefs(webBrowser));
            nsCOMPtr<nsIWebNavigation> webNavigation(do_QueryInterface(webBrowser));
            nsCOMPtr<nsIURI> currentURI;
            webNavigation->GetCurrentURI(getter_AddRefs(currentURI));
            if (currentURI == NULL)
                SendSocketMessage(instance, CEVENT_RETURN_URL, "");
            else { 
            	nsEmbedCString uriString;
                currentURI->GetAsciiSpec(uriString);
                SendSocketMessage(instance, CEVENT_RETURN_URL, uriString.get());
            }
        }
        break;

    case JEVENT_FOCUSGAINED:
    case JEVENT_FOCUSLOST:
        {
            pBrowser = (GtkBrowser *)gBrowserArray[instance];
            NS_ASSERTION(pBrowser, "Can't get native browser instance\n");

            if (!pBrowser->topLevelWindow) {
                ReportError("Top level Window is Null!\n");
                break;
            }

            GtkWidget *widget = GTK_WIDGET (pBrowser->topLevelWindow);
            GdkEvent event;

            GtkWindowClass *parent_class = (GtkWindowClass*) gtk_type_class (GTK_TYPE_WINDOW);

            if (!widget) {
                ReportError("Failed to get browser's toplevel window !\n");
                break;
            }
            if (!parent_class) {
                ReportError("Failed to get gtk window class !\n");
                break;
            }

            event.focus_change.type = GDK_FOCUS_CHANGE;
            event.focus_change.window = widget->window;
            event.focus_change.send_event = TRUE;

            if (type == JEVENT_FOCUSGAINED) {
                event.focus_change.in = TRUE;
                GTK_WIDGET_CLASS (parent_class)->focus_in_event
                            (widget, (GdkEventFocus *)&event);
            }
            else {
                event.focus_change.in = FALSE;
                GTK_WIDGET_CLASS (parent_class)->focus_out_event
                            (widget, (GdkEventFocus *)&event);
            }
        }
        break;
    case JEVENT_GETCONTENT:
        {
            pBrowser = (GtkBrowser *)gBrowserArray[instance];
            NS_ASSERTION(pBrowser, "Can't get native browser instance\n");
            nsCOMPtr<nsIWebBrowser> webBrowser;
            gtk_moz_embed_get_nsIWebBrowser(GTK_MOZ_EMBED(pBrowser->mozEmbed), 
                    getter_AddRefs(webBrowser));
            nsCOMPtr<nsIWebNavigation> 
                webNavigation(do_QueryInterface(webBrowser));
                                                                                                            
            char *retStr = GetContent(webNavigation);
            if (retStr == NULL)
                SendSocketMessage(instance, CEVENT_GETCONTENT, "");
            else
                SendSocketMessage(instance, CEVENT_GETCONTENT, retStr);
        } 
        break;
    case JEVENT_SETCONTENT:
        {
            NS_ASSERTION(i == 3, "Wrong message format\n");
            pBrowser = (GtkBrowser *)gBrowserArray[instance];
            NS_ASSERTION(pBrowser, "Can't get native browser instance\n");
            nsCOMPtr<nsIWebBrowser> webBrowser;
            gtk_moz_embed_get_nsIWebBrowser(GTK_MOZ_EMBED(pBrowser->mozEmbed), 
                    getter_AddRefs(webBrowser));
            nsCOMPtr<nsIWebNavigation> 
                webNavigation(do_QueryInterface(webBrowser));
            
            SetContent(webNavigation, mMsgString);
        }
        break;
    case JEVENT_EXECUTESCRIPT:
        {
            NS_ASSERTION(i == 3, "Wrong message format\n");
            pBrowser = (GtkBrowser *)gBrowserArray[instance];
            NS_ASSERTION(pBrowser, "Can't get native browser instance\n");
            nsCOMPtr<nsIWebBrowser> webBrowser;
            gtk_moz_embed_get_nsIWebBrowser(GTK_MOZ_EMBED(pBrowser->mozEmbed), 
                    getter_AddRefs(webBrowser));
            nsCOMPtr<nsIWebNavigation> 
                webNavigation(do_QueryInterface(webBrowser));
                                                                                                            
            char *retStr = ExecuteScript(webNavigation, mMsgString);
            if (retStr == NULL)
                SendSocketMessage(instance, CEVENT_EXECUTESCRIPT, "");
            else
                SendSocketMessage(instance, CEVENT_EXECUTESCRIPT, retStr);
        } 
        break;
    }
}
示例#13
0
/**
 * Redirect the Gecko engine to a given address
 *
 * @param newUrl - a fully resolved URL
 */
void GeckoEmbed::setUrl(const string& newUrl) {
	gtk_moz_embed_load_url(GeckoEmbed::getMozEmbed(), newUrl.c_str());
}