]> git.decadent.org.uk Git - videolink.git/commitdiff
Replaced BrowserWidget::init with a class that ensures proper initialisation and...
authorBen Hutchings <ben@decadent.org.uk>
Thu, 15 Dec 2005 00:50:23 +0000 (00:50 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Sun, 2 Nov 2008 23:19:48 +0000 (23:19 +0000)
Changed main() to use this and to set necessary browser preferences once it's instantiated.

browserwidget.cpp
browserwidget.hpp
webdvd.cpp

index 77c18469339a2280c92833e44efd2e304d3a2799..a2bed64ad4973ab8aa79d5ebf85b9942a3ec713e 100644 (file)
@@ -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)
index 1d1e85dec005a96cbb4196156d18859ab065a606..2cfc1d7ca15b0c2ab38cfc9a0c156dbec644a17d 100644 (file)
@@ -56,9 +56,13 @@ public:
     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);
index ceefb7804d446614ce69676bb8e6bbc05982aca7..5eca6c87eafe5a43d865241cff4e83df9b6df3e8 100644 (file)
 #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>
 
@@ -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<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)
@@ -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);