6f340e9462
git-svn-id: https://svn.disconnected-by-peer.at/svn/linamh/trunk/linamh@602 6952d904-891a-0410-993b-d76249ca496b
373 lines
13 KiB
Diff
373 lines
13 KiB
Diff
Index: extensions/gtkmoz_browser_element/browser_element.cc
|
|
===================================================================
|
|
--- extensions/gtkmoz_browser_element/browser_element.cc (revision 712)
|
|
+++ extensions/gtkmoz_browser_element/browser_element.cc (revision 713)
|
|
@@ -384,10 +384,6 @@
|
|
std::string down_fd_str = StringPrintf("%d", down_pipe_fds[0]);
|
|
std::string up_fd_str = StringPrintf("%d", up_pipe_fds[1]);
|
|
std::string ret_fd_str = StringPrintf("%d", ret_pipe_fds[0]);
|
|
-#ifdef MOZILLA_FIVE_HOME
|
|
- // Set appropriate environment variable for running mozilla gecko.
|
|
- setenv("MOZILLA_FIVE_HOME", MOZILLA_FIVE_HOME, 0);
|
|
-#endif
|
|
for (size_t i = 0; kBrowserChildNames[i]; ++i) {
|
|
execl(kBrowserChildNames[i], kBrowserChildNames[i],
|
|
down_fd_str.c_str(), up_fd_str.c_str(),
|
|
Index: extensions/gtkmoz_browser_element/browser_child.cc
|
|
===================================================================
|
|
--- extensions/gtkmoz_browser_element/browser_child.cc (revision 712)
|
|
+++ extensions/gtkmoz_browser_element/browser_child.cc (revision 713)
|
|
@@ -25,12 +25,18 @@
|
|
#include <gtk/gtk.h>
|
|
|
|
#define MOZILLA_CLIENT
|
|
+
|
|
+#ifdef XPCOM_GLUE
|
|
+#include <gtkmozembed_glue.cpp>
|
|
+#endif
|
|
+
|
|
#include <mozilla-config.h>
|
|
#include <gtkmozembed.h>
|
|
#include <gtkmozembed_internal.h>
|
|
#include <jsapi.h>
|
|
#include <jsconfig.h>
|
|
|
|
+#include <nsComponentManagerUtils.h>
|
|
#include <nsCOMPtr.h>
|
|
#include <nsCRT.h>
|
|
#include <nsEvent.h>
|
|
@@ -772,9 +778,9 @@
|
|
// Register external object (Javascript window.external object).
|
|
g_external_object.AddRef();
|
|
nsCOMPtr<nsIGenericFactory> factory;
|
|
- rv = NS_NewGenericFactory(getter_AddRefs(factory),
|
|
- &kExternalObjectComponentInfo);
|
|
+ factory = do_CreateInstance ("@mozilla.org/generic-factory;1", &rv);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
+ factory->SetComponentInfo(&kExternalObjectComponentInfo);
|
|
rv = registrar->RegisterFactory(kExternalObjectComponentInfo.mCID,
|
|
EXTOBJ_CLASSNAME, EXTOBJ_CONTRACTID,
|
|
factory);
|
|
@@ -787,9 +793,9 @@
|
|
|
|
// Register customized content policy.
|
|
g_content_policy.AddRef();
|
|
- rv = NS_NewGenericFactory(getter_AddRefs(factory),
|
|
- &kContentPolicyComponentInfo);
|
|
+ factory = do_CreateInstance ("@mozilla.org/generic-factory;1", &rv);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
+ factory->SetComponentInfo(&kContentPolicyComponentInfo);
|
|
rv = registrar->RegisterFactory(kContentPolicyComponentInfo.mCID,
|
|
CONTENT_POLICY_CLASSNAME,
|
|
CONTENT_POLICY_CONTRACTID,
|
|
@@ -803,8 +809,64 @@
|
|
return rv;
|
|
}
|
|
|
|
+static bool InitGecko() {
|
|
+#ifdef XPCOM_GLUE
|
|
+ nsresult rv;
|
|
+
|
|
+ NS_LogInit();
|
|
+ static const GREVersionRange kGREVersion = {
|
|
+ "1.9a", PR_TRUE,
|
|
+ "1.9.*", PR_TRUE
|
|
+ };
|
|
+
|
|
+ char xpcom_location[4096];
|
|
+ rv = GRE_GetGREPathWithProperties(&kGREVersion, 1, nsnull, 0, xpcom_location, 4096);
|
|
+ if (NS_FAILED(rv)) {
|
|
+ g_warning("Failed to find proper Gecko Runtime Environment!");
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ // Startup the XPCOM Glue that links us up with XPCOM.
|
|
+ rv = XPCOMGlueStartup(xpcom_location);
|
|
+ if (NS_FAILED(rv)) {
|
|
+ g_warning("Failed to startup XPCOM Glue!");
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ rv = GTKEmbedGlueStartup();
|
|
+ if (NS_FAILED(rv)) {
|
|
+ g_warning("Failed to startup Gtk Embed Glue!");
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ rv = GTKEmbedGlueStartupInternal();
|
|
+ if (NS_FAILED(rv)) {
|
|
+ g_warning("Failed to startup Gtk Embed Glue (internal)!");
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ char *last_slash = strrchr(xpcom_location, '/');
|
|
+ if (last_slash)
|
|
+ *last_slash = '\0';
|
|
+
|
|
+ gtk_moz_embed_set_path(xpcom_location);
|
|
+#elif defined(MOZILLA_FIVE_HOME)
|
|
+ gtk_moz_embed_set_comp_path(MOZILLA_FIVE_HOME);
|
|
+#endif
|
|
+ return true;
|
|
+}
|
|
+
|
|
int main(int argc, char **argv) {
|
|
+ if (!g_thread_supported())
|
|
+ g_thread_init(NULL);
|
|
+
|
|
gtk_init(&argc, &argv);
|
|
+
|
|
+ if (!InitGecko()) {
|
|
+ g_warning("Failed to initialize Gecko.");
|
|
+ return 1;
|
|
+ }
|
|
+
|
|
signal(SIGPIPE, OnSigPipe);
|
|
if (argc >= 2)
|
|
g_down_fd = g_ret_fd = static_cast<int>(strtol(argv[1], NULL, 0));
|
|
Index: hosts/gtk/sidebar_gtk_host.cc
|
|
===================================================================
|
|
--- hosts/gtk/sidebar_gtk_host.cc (revision 712)
|
|
+++ hosts/gtk/sidebar_gtk_host.cc (revision 713)
|
|
@@ -203,9 +203,9 @@
|
|
|
|
void OnHotKeyPressed() {
|
|
if (!gadgets_shown_ || sidebar_->IsMinimized())
|
|
- ShowOrHideAllGadgets(true);
|
|
+ ShowOrHideAll(true);
|
|
else
|
|
- ShowOrHideAllGadgets(false);
|
|
+ ShowOrHideAll(false);
|
|
}
|
|
|
|
void OnWorkAreaChange() {
|
|
@@ -356,9 +356,9 @@
|
|
|
|
void OnSideBarClose() {
|
|
if (!gadgets_shown_ || sidebar_->IsMinimized())
|
|
- ShowOrHideAllGadgets(true);
|
|
+ ShowOrHideAll(true);
|
|
else
|
|
- ShowOrHideAllGadgets(false);
|
|
+ ShowOrHideAll(false);
|
|
}
|
|
|
|
void OnSideBarSizeEvent() {
|
|
@@ -1142,9 +1142,14 @@
|
|
return false;
|
|
}
|
|
|
|
+ void ShowOrHideAll(bool show) {
|
|
+ DLOG("ShowOrHideAll(%d)", show);
|
|
+ ShowOrHideSideBar(show);
|
|
+ ShowOrHideAllGadgets(show);
|
|
+ gadgets_shown_ = show;
|
|
+ }
|
|
+
|
|
void ShowOrHideAllGadgets(bool show) {
|
|
- DLOG("ShowOrHideAllGadgets(%d)", show);
|
|
- ShowOrHideSideBar(show);
|
|
for (GadgetsMap::iterator it = gadgets_.begin();
|
|
it != gadgets_.end(); ++it) {
|
|
if (it->second.gadget->GetDisplayTarget() != Gadget::TARGET_SIDEBAR) {
|
|
@@ -1158,7 +1163,6 @@
|
|
OnMainViewPopIn(it->first);
|
|
}
|
|
}
|
|
- gadgets_shown_ = show;
|
|
}
|
|
|
|
void ShowOrHideSideBar(bool show) {
|
|
@@ -1421,11 +1425,11 @@
|
|
}
|
|
|
|
void ShowAllMenuHandler(const char *str) {
|
|
- ShowOrHideAllGadgets(true);
|
|
+ ShowOrHideAll(true);
|
|
}
|
|
|
|
void HideAllMenuHandler(const char *str) {
|
|
- ShowOrHideAllGadgets(false);
|
|
+ ShowOrHideAll(false);
|
|
}
|
|
|
|
void AutoHideMenuHandler(const char *str) {
|
|
@@ -1551,6 +1555,9 @@
|
|
g_source_remove(impl->auto_hide_source_);
|
|
impl->auto_hide_source_ = 0;
|
|
}
|
|
+ if (widget == impl->sidebar_window_ && !impl->sidebar_->IsMinimized()) {
|
|
+ impl->ShowOrHideAllGadgets(true);
|
|
+ }
|
|
return FALSE;
|
|
}
|
|
|
|
@@ -1613,9 +1620,9 @@
|
|
#if GTK_CHECK_VERSION(2,10,0) && defined(GGL_HOST_LINUX)
|
|
static void StatusIconActivateHandler(GtkWidget *widget, Impl *impl) {
|
|
if (!impl->gadgets_shown_ || impl->sidebar_->IsMinimized())
|
|
- impl->ShowOrHideAllGadgets(true);
|
|
+ impl->ShowOrHideAll(true);
|
|
else
|
|
- impl->ShowOrHideAllGadgets(false);
|
|
+ impl->ShowOrHideAll(false);
|
|
}
|
|
|
|
static void StatusIconPopupMenuHandler(GtkWidget *widget, guint button,
|
|
Index: ggadget/gtk/single_view_host.cc
|
|
===================================================================
|
|
--- ggadget/gtk/single_view_host.cc (revision 712)
|
|
+++ ggadget/gtk/single_view_host.cc (revision 713)
|
|
@@ -339,9 +339,9 @@
|
|
if (record_states_)
|
|
LoadWindowStates();
|
|
|
|
- // Show window immediately. So that following calls against the window can
|
|
- // take effect immediately.
|
|
- gtk_widget_show_now(window_);
|
|
+ // Can't use gtk_widget_show_now() here, because in some cases, it'll cause
|
|
+ // nested main loop and prevent ggl-gtk from being quitted.
|
|
+ gtk_widget_show(window_);
|
|
gtk_window_present(GTK_WINDOW(window_));
|
|
gdk_window_raise(window_->window);
|
|
|
|
Index: ggadget/decorated_view_host.cc
|
|
===================================================================
|
|
--- ggadget/decorated_view_host.cc (revision 712)
|
|
+++ ggadget/decorated_view_host.cc (revision 713)
|
|
@@ -82,6 +82,7 @@
|
|
hittest_(HT_CLIENT),
|
|
child_resizable_(ViewInterface::RESIZABLE_ZOOM),
|
|
auto_restore_view_size_(true),
|
|
+ view_state_restored_(false),
|
|
child_view_(NULL),
|
|
view_element_(new ViewElement(NULL, this, NULL, false)) {
|
|
view_element_->SetVisible(true);
|
|
@@ -104,6 +105,7 @@
|
|
child_view_ = child_view;
|
|
view_element_->SetChildView(child_view);
|
|
|
|
+ view_state_restored_ = false;
|
|
if (child_view_) {
|
|
child_resizable_ = child_view_->GetResizable();
|
|
|
|
@@ -401,7 +403,8 @@
|
|
}
|
|
|
|
virtual void SaveViewStates() {
|
|
- if (!auto_restore_view_size_)
|
|
+ // Don't save view state if the view state is not restored yet.
|
|
+ if (!auto_restore_view_size_ || !view_state_restored_)
|
|
return;
|
|
View *child = GetChildView();
|
|
Gadget *gadget = child ? child->GetGadget() : NULL;
|
|
@@ -430,7 +433,8 @@
|
|
View *child = GetChildView();
|
|
Gadget *gadget = child ? child->GetGadget() : NULL;
|
|
// Only load view states when the original size has been saved.
|
|
- if (gadget) {
|
|
+ // Only restore view state once.
|
|
+ if (gadget && !view_state_restored_) {
|
|
OptionsInterface *opt = gadget->GetOptions();
|
|
ViewElement *elm = GetViewElement();
|
|
std::string prefix(option_prefix_);
|
|
@@ -458,6 +462,9 @@
|
|
DLOG("RestoreViewStates(%d): w:%.0lf h:%.0lf s: %.2lf",
|
|
gadget->GetInstanceID(), elm->GetPixelWidth(),
|
|
elm->GetPixelHeight(), elm->GetScale());
|
|
+
|
|
+ // It's safe to save view state from now on.
|
|
+ view_state_restored_ = true;
|
|
UpdateViewSize();
|
|
UpdateChildViewSize();
|
|
}
|
|
@@ -533,6 +540,7 @@
|
|
HitTest hittest_;
|
|
ViewInterface::ResizableMode child_resizable_;
|
|
bool auto_restore_view_size_;
|
|
+ bool view_state_restored_;
|
|
|
|
View *child_view_;
|
|
ViewElement *view_element_;
|
|
@@ -850,7 +858,7 @@
|
|
|
|
virtual void SaveViewStates() {
|
|
Gadget *gadget = GetGadget();
|
|
- if (gadget) {
|
|
+ if (gadget && minimized_state_loaded_) {
|
|
OptionsInterface *opt = gadget->GetOptions();
|
|
opt->PutInternalValue("main_view_minimized", Variant(minimized_));
|
|
DLOG("SaveViewStates(%d): main view minimized: %s",
|
|
Index: configure.ac
|
|
===================================================================
|
|
--- configure.ac (revision 712)
|
|
+++ configure.ac (revision 713)
|
|
@@ -551,15 +551,25 @@
|
|
PKG_CHECK_MODULES(RSVG, librsvg-2.0 >= 2.14.0, [has_rsvg=yes], [has_rsvg=no])
|
|
|
|
# Check gtkmozembed
|
|
-PKG_CHECK_MODULES(GTKMOZEMBED, [xulrunner-gtkmozembed xulrunner-js],
|
|
- [has_gtkmozembed=xulrunner-gtkmozembed],
|
|
- [PKG_CHECK_MODULES(GTKMOZEMBED, [firefox2-gtkmozembed firefox2-js],
|
|
- [has_gtkmozembed=firefox2-gtkmozembed],
|
|
- [PKG_CHECK_MODULES(GTKMOZEMBED, [firefox-gtkmozembed firefox-js],
|
|
- [has_gtkmozembed=firefox-gtkmozembed],
|
|
- [PKG_CHECK_MODULES(GTKMOZEMBED, [mozilla-gtkmozembed mozilla-js],
|
|
- [has_gtkmozembed=mozilla-gtkmozembed],
|
|
- [has_gtkmozembed=no])])])])
|
|
+# Check priority:
|
|
+# xulrunner 1.9: mozilla-gtkmozembed-embedding and mozilla-js
|
|
+# xulrunner 1.9: libxul-embedding-unstable and mozilla-js
|
|
+# xulrunner 1.8: xulrunner-gtkmozembed and xulrunner-js
|
|
+# firefox 2.0: firefox2-gtkmozembed and firefox2-js
|
|
+# firefox 1.5: firefox-gtkmozembed and firefox-js
|
|
+#
|
|
+# Add more rules here if your distribution doesn't support above rules.
|
|
+PKG_CHECK_MODULES(GTKMOZEMBED, [mozilla-gtkmozembed-embedding mozilla-js],
|
|
+ [has_gtkmozembed=mozilla-gtkmozembed-embedding],
|
|
+ [PKG_CHECK_MODULES(GTKMOZEMBED, [libxul-embedding-unstable mozilla-js],
|
|
+ [has_gtkmozembed=libxul-embedding-unstable],
|
|
+ [PKG_CHECK_MODULES(GTKMOZEMBED, [xulrunner-gtkmozembed xulrunner-js],
|
|
+ [has_gtkmozembed=xulrunner-gtkmozembed],
|
|
+ [PKG_CHECK_MODULES(GTKMOZEMBED, [firefox2-gtkmozembed firefox2-js],
|
|
+ [has_gtkmozembed=firefox2-gtkmozembed],
|
|
+ [PKG_CHECK_MODULES(GTKMOZEMBED, [firefox-gtkmozembed firefox-js],
|
|
+ [has_gtkmozembed=firefox-gtkmozembed],
|
|
+ [has_gtkmozembed=no])])])])])
|
|
|
|
if test x$has_dbus = xyes; then
|
|
AC_DEFINE(HAVE_DBUS_LIBRARY,1,[Have dbus library])
|
|
@@ -677,21 +687,26 @@
|
|
GTKMOZEMBED_CFLAGS="$GTKMOZEMBED_CFLAGS -I$EMBED_INCDIR/dom"
|
|
GTKMOZEMBED_CFLAGS="$GTKMOZEMBED_CFLAGS -I$EMBED_INCDIR/xpconnect"
|
|
GTKMOZEMBED_CFLAGS="$GTKMOZEMBED_CFLAGS -I$EMBED_INCDIR/widget"
|
|
+ GTKMOZEMBED_LDFLAGS=""
|
|
MOZILLA_FIVE_HOME=`$PKG_CONFIG --variable=libdir $has_gtkmozembed`
|
|
if test "x$MOZILLA_FIVE_HOME" = "x"; then
|
|
# Some distributions doesn't have libdir, so try to extract libdir from LIBS.
|
|
+# It usually occurs on some pre xulrunner 1.9 versions.
|
|
# @<:@ and @:>@ will be replace by [ and ] by M4. Really evil.
|
|
+# FIXME: Following method might not work on systems other than Linux.
|
|
MOZILLA_FIVE_HOME=`echo $GTKMOZEMBED_LIBS | sed -e 's/.*-L\(@<:@^ @:>@*\) .*/\1/'`
|
|
- if test ! -e "$MOZILLA_FIVE_HOME"; then
|
|
- MOZILLA_FIVE_HOME=""
|
|
+ # Try to find out the correct xulrunner path.
|
|
+ if test -e "$MOZILLA_FIVE_HOME/libxpcom.so"; then
|
|
+ XPCOM_PATH=`readlink -f $MOZILLA_FIVE_HOME/libxpcom.so`
|
|
+ MOZILLA_FIVE_HOME=`dirname $XPCOM_PATH`
|
|
fi
|
|
fi
|
|
- PREDEFINED_MACROS="$PREDEFINED_MACROS -DMOZILLA_FIVE_HOME=\\\"$MOZILLA_FIVE_HOME\\\""
|
|
- AC_SUBST(MOZILLA_FIVE_HOME)
|
|
- if test "x$MOZILLA_FIVE_HOME" != "x"; then
|
|
+ if test "x$MOZILLA_FIVE_HOME" != "x" -a -d "$MOZILLA_FIVE_HOME"; then
|
|
+ GTKMOZEMBED_CFLAGS="$GTKMOZEMBED_CFLAGS -DMOZILLA_FIVE_HOME=\\\"$MOZILLA_FIVE_HOME\\\""
|
|
GTKMOZEMBED_LDFLAGS="$GTKMOZEMBED_LDFLAGS -R$MOZILLA_FIVE_HOME"
|
|
- AC_SUBST(GTKMOZEMBED_LDFLAGS)
|
|
fi
|
|
+
|
|
+ AC_SUBST(GTKMOZEMBED_LDFLAGS)
|
|
fi
|
|
|
|
AM_CONDITIONAL(
|