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)
Glib::SignalProxy0<void> signal_destroy();
Glib::SignalProxy1<bool, const char * /*uri*/> 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);
#include <nsIInterfaceRequestorUtils.h>
#include <nsIURI.h> // required before nsILink.h
#include <nsILink.h>
+#include <nsIPrefBranch.h>
+#include <nsIPrefService.h>
#include <nsIPresContext.h>
#include <nsIPresShell.h>
+#include <nsIServiceManagerUtils.h>
#include <nsIWebBrowser.h>
#include <nsString.h>
" [--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<nsIPrefService> pref_service;
+ static const nsCID pref_service_cid = NS_PREFSERVICE_CID;
+ check(CallGetService<nsIPrefService>(pref_service_cid,
+ getter_AddRefs(pref_service)));
+ nsCOMPtr<nsIPrefBranch> 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)
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);