From de16324e78d1c7e740ff8e136cfa0fc3c98f3fef Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Thu, 15 Dec 2005 00:50:23 +0000 Subject: [PATCH] Replaced BrowserWidget::init with a class that ensures proper initialisation and cleanup (I think). Changed main() to use this and to set necessary browser preferences once it's instantiated. --- browserwidget.cpp | 9 ++++++++- browserwidget.hpp | 10 +++++++--- webdvd.cpp | 30 +++++++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/browserwidget.cpp b/browserwidget.cpp index 77c1846..a2bed64 100644 --- a/browserwidget.cpp +++ b/browserwidget.cpp @@ -516,12 +516,19 @@ Glib::ObjectBase * BrowserWidget::wrap_new(GObject * gobject) return new BrowserWidget(gobject, false); } -void BrowserWidget::init() +BrowserWidget::Initialiser::Initialiser() { gtk_moz_embed_set_comp_path(MOZ_LIB_DIR); + gtk_moz_embed_push_startup(); + wrap_register(gtk_moz_embed_get_type(), wrap_new); } +BrowserWidget::Initialiser::~Initialiser() +{ + gtk_moz_embed_pop_startup(); +} + namespace Glib { BrowserWidget * wrap(GtkMozEmbed * object, bool take_copy) diff --git a/browserwidget.hpp b/browserwidget.hpp index 1d1e85d..2cfc1d7 100644 --- a/browserwidget.hpp +++ b/browserwidget.hpp @@ -56,9 +56,13 @@ public: Glib::SignalProxy0 signal_destroy(); Glib::SignalProxy1 signal_open_uri(); - // This must be called after Gtk initialisation and before instantiation - // of BrowserWidget. - static void init(); + // This must be instantiated after Gtk initialisation and before + // instantiation of BrowserWidget. + struct Initialiser + { + Initialiser(); + ~Initialiser(); + }; private: BrowserWidget(GObject * gobject, bool take_copy); diff --git a/webdvd.cpp b/webdvd.cpp index ceefb78..5eca6c8 100644 --- a/webdvd.cpp +++ b/webdvd.cpp @@ -42,8 +42,11 @@ #include #include // required before nsILink.h #include +#include +#include #include #include +#include #include #include @@ -975,6 +978,30 @@ namespace " [--preview] menu-url [output-dir]\n"); } + void set_browser_preferences() + { + // Disable IE-compatibility kluge that causes backgrounds to + // sometimes/usually be missing from snapshots. This is only + // effective from Mozilla 1.8 onward. +# if MOZ_VERSION_MAJOR > 1 \ + || (MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR >= 8) + nsCOMPtr pref_service; + static const nsCID pref_service_cid = NS_PREFSERVICE_CID; + check(CallGetService(pref_service_cid, + getter_AddRefs(pref_service))); + nsCOMPtr pref_branch; + check(pref_service->GetDefaultBranch("layout", + getter_AddRefs(pref_branch))); + check(pref_branch->SetBoolPref( + "fire_onload_after_image_background_loads", + true)); +# endif + + // TODO: Set display resolution? Unfortunately Mozilla doesn't + // support non-square pixels (and neither do fontconfig or Xft + // anyway). + } + } // namespace int main(int argc, char ** argv) @@ -1091,7 +1118,8 @@ int main(int argc, char ** argv) output_dir = argv[argi + 1]; // Initialise Mozilla - BrowserWidget::init(); + BrowserWidget::Initialiser browser_init; + set_browser_preferences(); // Run the browser/converter WebDvdWindow window(frame_params, menu_url, output_dir); -- 2.39.5