MozillaRenderer::MozillaRenderer()
{
	gtk_moz_embed_push_startup();

	// Create our web browser component
	m_htmlWidget = gtk_moz_embed_new();
	if (m_htmlWidget != NULL)
	{
		// Turn off all features
		gtk_moz_embed_set_chrome_mask(GTK_MOZ_EMBED(m_htmlWidget), GTK_MOZ_EMBED_FLAG_SCROLLBARSON);
#ifdef DEBUG
		cout << "MozillaRenderer::ctor: embedded Mozilla" << endl;
#endif
	}
#ifdef DEBUG
	else cerr << "MozillaRenderer::ctor: failed to embed Mozilla" << endl;
#endif
	m_rendering = false;
}
Пример #2
0
extern "C" void
gecko_utils_init(void)
{
	if (!g_thread_supported())
		g_thread_init(NULL);

        nsresult rv;

#ifdef XPCOM_GLUE
	NS_LogInit();

        static const GREVersionRange greVersion = {
                "1.9a", PR_TRUE,
                "1.9.*", PR_TRUE
        };

        char xpcomLocation[4096];
        rv = GRE_GetGREPathWithProperties(&greVersion, 1, nsnull, 0, xpcomLocation, 4096);
        if (NS_FAILED (rv))
        {
                g_warning ("Could not determine locale!\n");
                return;
        }

        // Startup the XPCOM Glue that links us up with XPCOM.
        rv = XPCOMGlueStartup(xpcomLocation);
        if (NS_FAILED (rv))
        {
                g_warning ("Could not determine locale!\n");
                return;
        }

        rv = GTKEmbedGlueStartup();
        if (NS_FAILED (rv))
        {
                g_warning ("Could not startup embed glue!\n");
                return;
        }

        rv = GTKEmbedGlueStartupInternal();
        if (NS_FAILED (rv))
        {
                g_warning ("Could not startup embed glue (internal)!\n");
                return;
        }

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

        gtk_moz_embed_set_path(xpcomLocation);
#else
	gtk_moz_embed_set_comp_path(GECKO_LIB_ROOT);
#endif

        gchar *profile_dir = g_build_filename(g_get_home_dir(),
                                              ".chmsee",
                                              NULL);

	gtk_moz_embed_set_profile_path(profile_dir, "mozilla");
	g_free(profile_dir);

	gtk_moz_embed_push_startup();

	gecko_utils_init_prefs();
}
Пример #3
0
int
mozembed_main(int argc, char **argv)
{
    if (argc > 1) {
        if (strstr(argv[1], "-port=")) {
            int port = atoi(&(argv[1][6]));
            gMessenger.SetPort(port);
            gMessenger.CreateServerSocket();
        }
        else if (strcmp(argv[1], "-test") == 0) {
            gTestMode = 1;
        }
    }
    
    if (!gTestMode && gMessenger.IsFailed()) {
        ReportError("Failed to create server socket!");
        exit(1);
    }

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

    // force the startup code to be executed because we need to start
    // the profile in a different way
    gtk_moz_embed_push_startup();

    if (NS_FAILED(InitializeProfile())) {
        ReportError("Failed to initialize profile!");
        exit(1);
    }

    gMsgLock = PR_NewLock();

    if (!gTestMode) {
        PRThread *socketListenThread = 
          PR_CreateThread(PR_USER_THREAD,
                          PortListening,
                          (void*)SocketMsgHandler,
                          PR_PRIORITY_NORMAL,
                          PR_GLOBAL_THREAD,
                          PR_UNJOINABLE_THREAD,
                          0);
        if (!socketListenThread) {
            ReportError("Failed to create socket listening thread!");
            exit(1);
        }

        // add event source to process socket messages
#ifdef MOZ_WIDGET_GTK
        g_source_add (GDK_PRIORITY_EVENTS, TRUE, &event_funcs, NULL, NULL, NULL);
#endif
#ifdef MOZ_WIDGET_GTK2
        GSource *newsource = g_source_new(&event_funcs, sizeof(GSource));
        g_source_attach(newsource, NULL);
#endif
    }
    else {
        GtkBrowser *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);
    }

    // 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) {
        ReportError("Failed to get singleton embed object!");
        exit(1);
    }

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

    gtk_main();
    gtk_moz_embed_pop_startup();

    PR_DestroyLock(gMsgLock);
    return 0;
}
Пример #4
0
/**
 * Start the Gecko engine (must call before gtk_main())
 */
void GeckoEmbed::bringUp() {
	gtk_moz_embed_push_startup();
}
Пример #5
0
extern "C" gboolean
gecko_init (void)
{
	d("gecko_init()\n");
	nsresult rv;
#ifdef HAVE_GECKO_1_9
	NS_LogInit ();
#endif

#ifdef XPCOM_GLUE
	static const GREVersionRange greVersion = {
	"1.9a", PR_TRUE,
	"2.0", PR_TRUE,
	};
	char xpcomLocation[4096];
	d("init XPCOM_GLUE\n");
	rv = GRE_GetGREPathWithProperties(
		&greVersion, 1, nsnull, 0, xpcomLocation, 4096);
	if (NS_FAILED (rv))
	{
		g_warning ("Could not determine locale!\n");
		return FALSE;
	}

	// Startup the XPCOM Glue that links us up with XPCOM.
	rv = XPCOMGlueStartup(xpcomLocation);
	if (NS_FAILED (rv))
	{
		g_warning ("Could not determine locale!\n");
		return FALSE;
	}

	rv = GTKEmbedGlueStartup();
	if (NS_FAILED (rv))
	{
		g_warning ("Could not startup glue!\n");
		return FALSE;
	}

	rv = GTKEmbedGlueStartupInternal();
	if (NS_FAILED (rv))
	{
		g_warning ("Could not startup internal glue!\n");
		return FALSE;
	}

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

	gtk_moz_embed_set_path(xpcomLocation);
#else
	d(g_print("doing old gecko init\n"));
#ifdef HAVE_GECKO_1_9
	gtk_moz_embed_set_path (GECKO_HOME);
#else
	gtk_moz_embed_set_comp_path (GECKO_HOME);
#endif
	d("end gecko init()\n");
#endif /* XPCOM_GLUE */

	d("load gecko prefs\n");
	gchar *profile_dir = g_build_filename (
				g_get_home_dir (),
				".evolution",
				"mail",
				"rss",
				NULL);

	gtk_moz_embed_set_profile_path (profile_dir, "mozembed-rss");
	g_free (profile_dir);

	d("embed push startup()\n");
	gtk_moz_embed_push_startup ();

	nsCOMPtr<nsIPrefService> prefService (
				do_GetService (NS_PREFSERVICE_CONTRACTID, &rv));
	NS_ENSURE_SUCCESS (rv, FALSE);

	rv = CallQueryInterface (prefService, &gPrefBranch);
	NS_ENSURE_SUCCESS (rv, FALSE);
	d("finished all gecko init\n");

	return TRUE;
}