]> git.decadent.org.uk Git - videolink.git/blobdiff - browser_widget.cpp
Release versions 1.2.11 and 1.2.11-1
[videolink.git] / browser_widget.cpp
index 46d1fb5e0ba97706c4d72414b9dad053464c9046..cff4a7dab2b52f8fb9362d0f74bc701036497686 100644 (file)
@@ -1,11 +1,24 @@
-// Copyright 2005 Ben Hutchings <ben@decadent.org.uk>.
+// Copyright 2005-8 Ben Hutchings <ben@decadent.org.uk>.
 // See the file "COPYING" for licence details.
 
 #include "browser_widget.hpp"
 
 #include <cassert>
+#include <cstring>
 
+#include <limits.h>
+
+#include "videolink.hpp"
+#include "wchar_t_short.h"
 #include <gtkmozembed_internal.h>
+#if MOZ_VERSION_GE(1,9,0)
+#include <gtkmozembed_glue.cpp>
+#endif
+#include "wchar_t_default.h"
+
+#include "xpcom_support.hpp"
+
+using xpcom_support::check;
 
 browser_widget::browser_widget()
        : Gtk::Bin(GTK_BIN(gtk_moz_embed_new()))
@@ -518,7 +531,40 @@ Glib::ObjectBase * browser_widget::wrap_new(GObject * gobject)
 
 browser_widget::initialiser::initialiser()
 {
+#if MOZ_VERSION_GE(1,9,0)
+    static const GREVersionRange gre_versions = {
+#if MOZ_VERSION_EQ(1,9,0)
+       "1.9a", PR_TRUE,
+       "1.9.1", PR_FALSE
+#elif MOZ_VERSION_EQ(1,9,1)
+       "1.9.1", PR_TRUE,
+       "1.9.2", PR_FALSE
+#elif MOZ_VERSION_EQ(2,0,-1) || MOZ_VERSION_EQ(2,0,0)
+       "2.0b", PR_TRUE,
+       "2.0.1", PR_FALSE
+#elif MOZ_VERSION_EQ(2,0,1)
+       "2.0.1", PR_TRUE,
+       "2.0.2", PR_FALSE
+#else
+#error "version is unsupported, but you could try continuing the pattern above"
+#endif
+    };
+    char path[PATH_MAX];
+    check(GRE_GetGREPathWithProperties(&gre_versions, 1, 0, 0,
+                                      path, sizeof(path)));
+
+    check(XPCOMGlueStartup(path));
+    check(GTKEmbedGlueStartup());
+    check(GTKEmbedGlueStartupInternal());
+
+    char * last_slash = std::strrchr(path, '/');
+    if (last_slash != path)
+       *last_slash = '\0';
+    gtk_moz_embed_set_path(path);
+#else
     gtk_moz_embed_set_comp_path(MOZ_LIB_DIR);
+#endif
+
     gtk_moz_embed_push_startup();
 
     wrap_register(gtk_moz_embed_get_type(), wrap_new);
@@ -527,6 +573,10 @@ browser_widget::initialiser::initialiser()
 browser_widget::initialiser::~initialiser()
 {
     gtk_moz_embed_pop_startup();
+
+#if MOZ_VERSION_GE(1,9,0)
+    XPCOMGlueShutdown();
+#endif
 }
 
 namespace Glib