Bug 627699 - Port GTK2 to GTK3, toolkit part, r=karlt
authorMartin Stransky <stransky@redhat.com>
Sat, 16 Jun 2012 18:06:10 +1200
changeset 102173 88d69928e3b12ce388ec282ea3ef2706eb847425
parent 102172 8e87bb0023f1fd407e2c3f14d30b5b8b545fb2b3
child 102174 ec910f35ce86422c5a7694d2bd374fc6eb352ff0
push id191
push userlsblakk@mozilla.com
push dateFri, 05 Oct 2012 17:12:53 +0000
treeherdermozilla-release@ddb22ac6c03b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs627699
milestone16.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 627699 - Port GTK2 to GTK3, toolkit part, r=karlt
toolkit/components/filepicker/nsFilePicker.manifest
toolkit/components/remote/nsGTKRemoteService.cpp
toolkit/content/widgets/findbar.xml
toolkit/content/widgets/tabbox.xml
toolkit/content/xul.css
toolkit/library/nsStaticXULComponents.cpp
toolkit/themes/winstripe/global/config.css
toolkit/themes/winstripe/global/dirListing/dirListing.css
toolkit/xre/nsAppRunner.cpp
toolkit/xre/nsEmbedFunctions.cpp
toolkit/xre/nsNativeAppSupportUnix.cpp
toolkit/xre/nsSigHandlers.cpp
--- a/toolkit/components/filepicker/nsFilePicker.manifest
+++ b/toolkit/components/filepicker/nsFilePicker.manifest
@@ -1,4 +1,4 @@
 component {54ae32f8-1dd2-11b2-a209-df7c505370f8} nsFilePicker.js
-#ifndef MOZ_WIDGET_GTK2
+#ifndef MOZ_WIDGET_GTK
 contract @mozilla.org/filepicker;1 {54ae32f8-1dd2-11b2-a209-df7c505370f8}
 #endif
--- a/toolkit/components/remote/nsGTKRemoteService.cpp
+++ b/toolkit/components/remote/nsGTKRemoteService.cpp
@@ -150,31 +150,40 @@ void
 nsGTKRemoteService::HandleCommandsFor(GtkWidget* widget,
                                       nsIWeakReference* aWindow)
 {
   g_signal_connect(G_OBJECT(widget), "property_notify_event",
                    G_CALLBACK(HandlePropertyChange), aWindow);
 
   gtk_widget_add_events(widget, GDK_PROPERTY_CHANGE_MASK);
 
+#if (MOZ_WIDGET_GTK == 2)
   Window window = GDK_WINDOW_XWINDOW(widget->window);
+#else
+  Window window = gdk_x11_window_get_xid(gtk_widget_get_window(widget));
+#endif
   nsXRemoteService::HandleCommandsFor(window);
 
 }
 
 gboolean
 nsGTKRemoteService::HandlePropertyChange(GtkWidget *aWidget,
                                          GdkEventProperty *pevent,
                                          nsIWeakReference *aThis)
 {
   if (pevent->state == GDK_PROPERTY_NEW_VALUE) {
     Atom changedAtom = gdk_x11_atom_to_xatom(pevent->atom);
 
-    return HandleNewProperty(GDK_WINDOW_XWINDOW(pevent->window),
-                             GDK_DISPLAY(),
+#if (MOZ_WIDGET_GTK == 2)
+    XID window = GDK_WINDOW_XWINDOW(pevent->window);
+#else
+    XID window = gdk_x11_window_get_xid(gtk_widget_get_window(aWidget));
+#endif
+    return HandleNewProperty(window,
+                             GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
                              pevent->time, changedAtom, aThis);
   }
   return FALSE;
 }
 
 
 // {C0773E90-5799-4eff-AD03-3EBCD85624AC}
 #define NS_REMOTESERVICE_CID \
--- a/toolkit/content/widgets/findbar.xml
+++ b/toolkit/content/widgets/findbar.xml
@@ -180,17 +180,17 @@
     <xul:hbox anonid="findbar-container" class="findbar-container" flex="1" align="center">
       <xul:toolbarbutton anonid="find-closebutton"
                          class="findbar-closebutton"
                          tooltiptext="&findCloseButton.tooltip;"
                          oncommand="close();"/>
       <xul:label anonid="find-label" class="findbar-find-fast" control="findbar-textbox"/>
       <xul:textbox class="findbar-textbox findbar-find-fast" anonid="findbar-textbox"
                    xbl:inherits="flash"/>
-#ifdef MOZ_WIDGET_GTK2
+#ifdef MOZ_WIDGET_GTK
       <xul:toolbarbutton anonid="find-previous"
                          class="findbar-find-previous tabbable"
                          label="&previous.label;"
                          accesskey="&previous.accesskey;"
                          tooltiptext="&previous.tooltip;"
                          oncommand="onFindAgainCommand(true);"
                          disabled="true"
                          xbl:inherits="accesskey=findpreviousaccesskey"/>
@@ -198,17 +198,17 @@
       <xul:toolbarbutton anonid="find-next"
                          class="findbar-find-next tabbable"
                          label="&next.label;"
                          accesskey="&next.accesskey;"
                          tooltiptext="&next.tooltip;"
                          oncommand="onFindAgainCommand(false);"
                          disabled="true"
                          xbl:inherits="accesskey=findnextaccesskey"/>
-#ifndef MOZ_WIDGET_GTK2
+#ifndef MOZ_WIDGET_GTK
       <xul:toolbarbutton anonid="find-previous"
                          class="findbar-find-previous tabbable"
                          label="&previous.label;"
                          accesskey="&previous.accesskey;"
                          tooltiptext="&previous.tooltip;"
                          oncommand="onFindAgainCommand(true);"
                          disabled="true"
                          xbl:inherits="accesskey=findpreviousaccesskey"/>
--- a/toolkit/content/widgets/tabbox.xml
+++ b/toolkit/content/widgets/tabbox.xml
@@ -572,17 +572,17 @@
           if (remove)
             this.removeChild(remove);
           return remove;
         ]]>
         </body>
       </method>
     </implementation>
 
-#ifdef MOZ_WIDGET_GTK2
+#ifdef MOZ_WIDGET_GTK
     <handlers>
       <handler event="DOMMouseScroll">
       <![CDATA[
         if (event.detail > 0)
           this.advanceSelectedTab(1, false);
         else
           this.advanceSelectedTab(-1, false);
 
--- a/toolkit/content/xul.css
+++ b/toolkit/content/xul.css
@@ -135,17 +135,17 @@ button[type="repeat"] {
 button[type="menu"], button[type="panel"] {
   -moz-binding: url("chrome://global/content/bindings/button.xml#menu");
 }
 
 button[type="menu-button"] {
   -moz-binding: url("chrome://global/content/bindings/button.xml#menu-button");
 }
 
-%ifdef MOZ_WIDGET_GTK2
+%ifdef MOZ_WIDGET_GTK
 /********* detection of system setting to use icons in buttons ***********/
 button[label]:not([label=""]) > .button-box > .button-icon:not(:-moz-system-metric(images-in-buttons)),
 button[label]:not([label=""]) > .button-box > .box-inherit > .button-icon:not(:-moz-system-metric(images-in-buttons)) {
   display: none;
 }
 %endif
 
 /********** toolbarbutton **********/
@@ -363,17 +363,17 @@ menuitem[type="checkbox"],
 menuitem[type="radio"] {
   -moz-binding: url("chrome://global/content/bindings/menu.xml#menuitem-iconic");
 }
 
 menuitem.menuitem-non-iconic {
   -moz-binding: url("chrome://global/content/bindings/menu.xml#menubutton-item");
 }
 
-%ifdef MOZ_WIDGET_GTK2
+%ifdef MOZ_WIDGET_GTK
 /********* detection of system setting to use icons in menus ***********/
 @media not all and (-moz-images-in-menus) {
   .menu-iconic-left {
     visibility: hidden;
   }
   :-moz-any(menuitem[type], .menuitem-with-favicon) > .menu-iconic-left {
     visibility: visible;
   }
--- a/toolkit/library/nsStaticXULComponents.cpp
+++ b/toolkit/library/nsStaticXULComponents.cpp
@@ -31,17 +31,17 @@
 #endif
 
 #ifdef XP_WIN
 #  define WIDGET_MODULES MODULE(nsWidgetModule)
 #elif defined(XP_MACOSX)
 #  define WIDGET_MODULES MODULE(nsWidgetMacModule)
 #elif defined(XP_OS2)
 #  define WIDGET_MODULES MODULE(nsWidgetOS2Module)
-#elif defined(MOZ_WIDGET_GTK2)
+#elif defined(MOZ_WIDGET_GTK)
 #  define WIDGET_MODULES MODULE(nsWidgetGtk2Module)
 #elif defined(MOZ_WIDGET_QT)
 #  define WIDGET_MODULES MODULE(nsWidgetQtModule)
 #elif defined(MOZ_WIDGET_ANDROID)
 #  define WIDGET_MODULES MODULE(nsWidgetAndroidModule)
 #elif defined(MOZ_WIDGET_GONK)
 #  define WIDGET_MODULES MODULE(nsWidgetGonkModule)
 #else
@@ -62,17 +62,17 @@
 
 #ifdef MOZ_ENABLE_XREMOTE
 #define XREMOTE_MODULES MODULE(RemoteServiceModule)
 #else
 #define XREMOTE_MODULES
 #endif
 
 #ifdef MOZ_PREF_EXTENSIONS
-#ifdef MOZ_ENABLE_GTK2
+#ifdef MOZ_ENABLE_GTK
 #define SYSTEMPREF_MODULES \
     MODULE(nsAutoConfigModule)
 #else
 #define SYSTEMPREF_MODULES MODULE(nsAutoConfigModule)
 #endif
 #else
 #define SYSTEMPREF_MODULES
 #endif
@@ -120,17 +120,17 @@
 
 #ifdef MOZ_SPELLCHECK
 #define SPELLCHECK_MODULE MODULE(mozSpellCheckerModule)
 #else
 #define SPELLCHECK_MODULE
 #endif
 
 #ifdef MOZ_XUL
-#ifdef MOZ_ENABLE_GTK2
+#ifdef MOZ_ENABLE_GTK
 #define UNIXPROXY_MODULE MODULE(nsUnixProxyModule)
 #endif
 #if defined(MOZ_WIDGET_QT)
 #define UNIXPROXY_MODULE MODULE(nsUnixProxyModule)
 #endif
 #endif
 #ifndef UNIXPROXY_MODULE
 #define UNIXPROXY_MODULE
--- a/toolkit/themes/winstripe/global/config.css
+++ b/toolkit/themes/winstripe/global/config.css
@@ -49,17 +49,17 @@
 
 #showWarningNextTime
 {
   margin-top: 0.6em;
 }
 
 #exclam
 {
-%ifdef MOZ_WIDGET_GTK2
+%ifdef MOZ_WIDGET_GTK
   list-style-image: url("moz-icon://stock/gtk-dialog-warning?size=dialog");
 %else
   list-style-image: url("chrome://global/skin/icons/warning-large.png");
 %endif
   -moz-margin-end: 3em;
 }
 
 #configTreeBody::-moz-tree-cell-text(user)
--- a/toolkit/themes/winstripe/global/dirListing/dirListing.css
+++ b/toolkit/themes/winstripe/global/dirListing/dirListing.css
@@ -91,23 +91,23 @@ td:not(:first-child) {
   padding: 0 .5em;
   -moz-margin-start: 20px;
 }
 
 .up::before {
   -moz-margin-end: 4px;
   -moz-margin-start: -20px;
   vertical-align: middle;
-%ifdef MOZ_WIDGET_GTK2
+%ifdef MOZ_WIDGET_GTK
   content: url(moz-icon://stock/gtk-go-up?size=menu);
 %else
   content: url(chrome://global/skin/dirListing/up.png);
 %endif
 }
 
 .dir::before {
-%ifdef MOZ_WIDGET_GTK2
+%ifdef MOZ_WIDGET_GTK
   content: url(moz-icon://stock/gtk-directory?size=menu);
 %else
   content: url(chrome://global/skin/dirListing/folder.png);
 %endif
 }
 
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -206,17 +206,17 @@ static nsIProfileLock* gProfileLock;
 int    gRestartArgc;
 char **gRestartArgv;
 
 #ifdef MOZ_WIDGET_QT
 static int    gQtOnlyArgc;
 static char **gQtOnlyArgv;
 #endif
 
-#if defined(MOZ_WIDGET_GTK2)
+#if defined(MOZ_WIDGET_GTK)
 #if defined(DEBUG) || defined(NS_BUILD_REFCNT_LOGGING) \
   || defined(NS_TRACE_MALLOC)
 #define CLEANUP_MEMORY 1
 #define PANGO_ENABLE_BACKEND
 #include <pango/pangofc-fontmap.h>
 #endif
 #include <gtk/gtk.h>
 #ifdef MOZ_X11
@@ -2504,17 +2504,17 @@ private:
   EXCEPTIONREGISTRATIONRECORD excpreg;
 
 public:
   ScopedFPHandler() { PR_OS2_SetFloatExcpHandler(&excpreg); }
   ~ScopedFPHandler() { PR_OS2_UnsetFloatExcpHandler(&excpreg); }
 };
 #endif
 
-#ifdef MOZ_WIDGET_GTK2
+#ifdef MOZ_WIDGET_GTK
 #include "prlink.h"
 typedef void (*_g_set_application_name_fn)(const gchar *application_name);
 typedef void (*_gtk_window_set_auto_startup_notification_fn)(gboolean setting);
 
 static PRFuncPtr FindFunction(const char* aName)
 {
   PRLibrary *lib = nsnull;
   PRFuncPtr result = PR_FindFunctionSymbolAndLibrary(aName, &lib);
@@ -2701,17 +2701,17 @@ public:
   XREMain() :
     mScopedXPCom(nsnull)
     , mAppData(nsnull)
     , mStartOffline(false)
     , mShuttingDown(false)
 #ifdef MOZ_ENABLE_XREMOTE
     , mDisableRemote(false)
 #endif
-#if defined(MOZ_WIDGET_GTK2)
+#if defined(MOZ_WIDGET_GTK)
     , mGdkDisplay(nsnull)
 #endif
   {};
 
   ~XREMain() {
     if (mAppData) {
       delete mAppData;
     }
@@ -2742,17 +2742,17 @@ public:
   nsCAutoString mDesktopStartupID;
 
   bool mStartOffline;
   bool mShuttingDown;
 #ifdef MOZ_ENABLE_XREMOTE
   bool mDisableRemote;
 #endif
 
-#if defined(MOZ_WIDGET_GTK2)
+#if defined(MOZ_WIDGET_GTK)
   GdkDisplay* mGdkDisplay;
 #endif
 };
 
 /*
  * XRE_mainInit - Initial setup and command line parameter processing.
  * Main() will exit early if either return value != 0 or if aExitFlag is
  * true.
@@ -3157,17 +3157,17 @@ XREMain::XRE_mainStartup(bool* aExitFlag
 {
   NS_TIME_FUNCTION;
   nsresult rv;
 
   if (!aExitFlag)
     return 1;
   *aExitFlag = false;
 
-#if defined(MOZ_WIDGET_GTK2) || defined(MOZ_ENABLE_XREMOTE)
+#if defined(MOZ_WIDGET_GTK) || defined(MOZ_ENABLE_XREMOTE)
   // Stash DESKTOP_STARTUP_ID in malloc'ed memory because gtk_init will clear it.
 #define HAVE_DESKTOP_STARTUP_ID
   const char* desktopStartupIDEnv = PR_GetEnv("DESKTOP_STARTUP_ID");
   if (desktopStartupIDEnv) {
     mDesktopStartupID.Assign(desktopStartupIDEnv);
   }
 #endif
 
@@ -3197,23 +3197,25 @@ XREMain::XRE_mainStartup(bool* aExitFlag
   for (int i = 1; i < gRestartArgc; ++i) {
     if (!nonQtArguments.contains(gRestartArgv[i])) {
       // copy arguments used by Qt for later
       gQtOnlyArgv[gQtOnlyArgc++] = gRestartArgv[i];
     }
   }
   gQtOnlyArgv[gQtOnlyArgc] = nsnull;
 #endif
-#if defined(MOZ_WIDGET_GTK2)
+#if defined(MOZ_WIDGET_GTK)
   // setup for private colormap.  Ideally we'd like to do this
   // in nsAppShell::Create, but we need to get in before gtk
   // has been initialized to make sure everything is running
   // consistently.
+#if (MOZ_WIDGET_GTK == 2)
   if (CheckArg("install"))
     gdk_rgb_set_install(TRUE);
+#endif
 
   // Initialize GTK here for splash.
 
   // Open the display ourselves instead of using gtk_init, so that we can
   // close it without fear that one day gtk might clean up the display it
   // opens.
   if (!gtk_parse_args(&gArgc, &gArgv))
     return 1;
@@ -3276,17 +3278,17 @@ XREMain::XRE_mainStartup(bool* aExitFlag
   // as to avoid overhead when omtc is not used. 
   // An environment variable is used instead of a pref on X11 platforms because we start having 
   // access to prefs long after the first call to XOpenDisplay which is hard to change due to 
   // interdependencies in the initialization.
   if (PR_GetEnv("MOZ_USE_OMTC")) {
     XInitThreads();
   }
 #endif
-#if defined(MOZ_WIDGET_GTK2)
+#if defined(MOZ_WIDGET_GTK)
   mGdkDisplay = gdk_display_open(display_name);
   if (!mGdkDisplay) {
     PR_fprintf(PR_STDERR, "Error: cannot open display: %s\n", display_name);
     return 1;
   }
   gdk_display_manager_set_default_display (gdk_display_manager_get(),
                                            mGdkDisplay);
     
@@ -3297,18 +3299,20 @@ XREMain::XRE_mainStartup(bool* aExitFlag
     _g_set_application_name(mAppData->name);
   }
   _gtk_window_set_auto_startup_notification_fn _gtk_window_set_auto_startup_notification =
     (_gtk_window_set_auto_startup_notification_fn)FindFunction("gtk_window_set_auto_startup_notification");
   if (_gtk_window_set_auto_startup_notification) {
     _gtk_window_set_auto_startup_notification(false);
   }
 
+#if (MOZ_WIDGET_GTK == 2)
   gtk_widget_set_default_colormap(gdk_rgb_get_colormap());
-#endif /* MOZ_WIDGET_GTK2 */
+#endif /* (MOZ_WIDGET_GTK == 2) */
+#endif /* defined(MOZ_WIDGET_GTK) */
 #ifdef MOZ_X11
   // Do this after initializing GDK, or GDK will install its own handler.
   InstallX11ErrorHandler();
 #endif
 
   // Call the code to install our handler
 #ifdef MOZ_JPROF
   setupProfilingStuff();
@@ -3319,17 +3323,17 @@ XREMain::XRE_mainStartup(bool* aExitFlag
     return 1;
 
   bool canRun = false;
   rv = mNativeApp->Start(&canRun);
   if (NS_FAILED(rv) || !canRun) {
     return 1;
   }
 
-#if defined(HAVE_DESKTOP_STARTUP_ID) && defined(MOZ_WIDGET_GTK2)
+#if defined(HAVE_DESKTOP_STARTUP_ID) && defined(MOZ_WIDGET_GTK)
   // DESKTOP_STARTUP_ID is cleared now,
   // we recover it in case we need a restart.
   if (!mDesktopStartupID.IsEmpty()) {
     nsCAutoString desktopStartupEnv;
     desktopStartupEnv.AssignLiteral("DESKTOP_STARTUP_ID=");
     desktopStartupEnv.Append(mDesktopStartupID);
     // Leak it with extreme prejudice!
     PR_SetEnv(ToNewCString(desktopStartupEnv));
@@ -3704,17 +3708,17 @@ XREMain::XRE_mainRun()
   NS_TIME_FUNCTION_MARK("env munging");
 
   if (!mShuttingDown) {
     NS_TIME_FUNCTION_MARK("Next: CreateHiddenWindow");
 
     rv = appStartup->CreateHiddenWindow();
     NS_ENSURE_SUCCESS(rv, 1);
 
-#if defined(HAVE_DESKTOP_STARTUP_ID) && defined(MOZ_WIDGET_GTK2)
+#if defined(HAVE_DESKTOP_STARTUP_ID) && defined(MOZ_WIDGET_GTK)
     nsGTKToolkit* toolkit = nsGTKToolkit::GetToolkit();
     if (toolkit && !mDesktopStartupID.IsEmpty()) {
       toolkit->SetDesktopStartupID(mDesktopStartupID);
     }
     // Clear the environment variable so it won't be inherited by
     // child processes and confuse things.
     g_unsetenv ("DESKTOP_STARTUP_ID");
 #endif
@@ -3814,17 +3818,17 @@ XREMain::XRE_main(int argc, char* argv[]
   mAppData = new ScopedAppData(aAppData);
   if (!mAppData)
     return 1;
   // used throughout this file
   gAppData = mAppData;
 
   ScopedLogging log;
 
-#if defined(MOZ_WIDGET_GTK2)
+#if defined(MOZ_WIDGET_GTK)
 #ifdef MOZ_MEMORY
   // Disable the slice allocator, since jemalloc already uses similar layout
   // algorithms, and using a sub-allocator tends to increase fragmentation.
   // This must be done before g_thread_init() is called.
   g_slice_set_config(G_SLICE_CONFIG_ALWAYS_MALLOC, 1);
 #endif
   g_thread_init(NULL);
 #endif
@@ -3893,30 +3897,30 @@ XREMain::XRE_main(int argc, char* argv[]
   if (appInitiatedRestart) {
     RestoreStateForAppInitiatedRestart();
 
     // Ensure that these environment variables are set:
     SaveFileToEnvIfUnset("XRE_PROFILE_PATH", mProfD);
     SaveFileToEnvIfUnset("XRE_PROFILE_LOCAL_PATH", mProfLD);
     SaveWordToEnvIfUnset("XRE_PROFILE_NAME", mProfileName);
 
-#ifdef MOZ_WIDGET_GTK2
+#ifdef MOZ_WIDGET_GTK
     MOZ_gdk_display_close(mGdkDisplay);
 #endif
 
     rv = LaunchChild(mNativeApp, true);
 
 #ifdef MOZ_CRASHREPORTER
     if (mAppData->flags & NS_XRE_ENABLE_CRASH_REPORTER)
       CrashReporter::UnsetExceptionHandler();
 #endif
     return rv == NS_ERROR_LAUNCHED_CHILD_PROCESS ? 0 : 1;
   }
 
-#ifdef MOZ_WIDGET_GTK2
+#ifdef MOZ_WIDGET_GTK
   // gdk_display_close also calls gdk_display_manager_set_default_display
   // appropriately when necessary.
   MOZ_gdk_display_close(mGdkDisplay);
 #endif
 
 #ifdef MOZ_CRASHREPORTER
   if (mAppData->flags & NS_XRE_ENABLE_CRASH_REPORTER)
       CrashReporter::UnsetExceptionHandler();
--- a/toolkit/xre/nsEmbedFunctions.cpp
+++ b/toolkit/xre/nsEmbedFunctions.cpp
@@ -6,17 +6,17 @@
 #include "nsQAppInstance.h"
 #endif
 
 #include "base/basictypes.h"
 
 #include "nsXULAppAPI.h"
 
 #include <stdlib.h>
-#if defined(MOZ_WIDGET_GTK2)
+#if defined(MOZ_WIDGET_GTK)
 #include <glib.h>
 #endif
 
 #include "prenv.h"
 
 #include "nsIAppShell.h"
 #include "nsIAppStartupNotifier.h"
 #include "nsIDirectoryService.h"
@@ -357,17 +357,17 @@ XRE_InitChildProcess(int aArgc,
 #  else
 #    error "OOP crash reporting unsupported on this platform"
 #  endif   
 #endif // if defined(MOZ_CRASHREPORTER)
 
   gArgv = aArgv;
   gArgc = aArgc;
 
-#if defined(MOZ_WIDGET_GTK2)
+#if defined(MOZ_WIDGET_GTK)
   g_thread_init(NULL);
 #endif
 
 #if defined(MOZ_WIDGET_QT)
   nsQAppInstance::AddRef();
 #endif
 
   if (PR_GetEnv("MOZ_DEBUG_CHILD_PROCESS")) {
--- a/toolkit/xre/nsNativeAppSupportUnix.cpp
+++ b/toolkit/xre/nsNativeAppSupportUnix.cpp
@@ -394,32 +394,34 @@ OssoModeControlCallback(DBusConnection *
 
 #endif
 
 NS_IMETHODIMP
 nsNativeAppSupportUnix::Start(bool *aRetVal)
 {
   NS_ASSERTION(gAppData, "gAppData must not be null.");
 
+#if (MOZ_WIDGET_GTK == 2)
   if (gtk_major_version < MIN_GTK_MAJOR_VERSION ||
       (gtk_major_version == MIN_GTK_MAJOR_VERSION && gtk_minor_version < MIN_GTK_MINOR_VERSION)) {
     GtkWidget* versionErrDialog = gtk_message_dialog_new(NULL,
                      GtkDialogFlags(GTK_DIALOG_MODAL |
                                     GTK_DIALOG_DESTROY_WITH_PARENT),
                      GTK_MESSAGE_ERROR,
                      GTK_BUTTONS_OK,
                      UNSUPPORTED_GTK_MSG,
                      gtk_major_version,
                      gtk_minor_version,
                      MIN_GTK_MAJOR_VERSION,
                      MIN_GTK_MINOR_VERSION);
     gtk_dialog_run(GTK_DIALOG(versionErrDialog));
     gtk_widget_destroy(versionErrDialog);
     exit(0);
   }
+#endif
 
 #if (MOZ_PLATFORM_MAEMO == 5)
   /* zero state out. */
   memset(&m_hw_state, 0, sizeof(osso_hw_state_t));
 
   /* Initialize maemo application
      
      The initalization name will be of the form "Vendor.Name".
@@ -454,17 +456,17 @@ nsNativeAppSupportUnix::Start(bool *aRet
   // Setup an MCE callback to monitor orientation
   DBusConnection *connnection = (DBusConnection*)osso_get_sys_dbus_connection(m_osso_context);
   dbus_bus_add_match(connnection, MCE_MATCH_RULE, nsnull);
   dbus_connection_add_filter(connnection, OssoModeControlCallback, nsnull, nsnull);
 #endif
 
   *aRetVal = true;
 
-#ifdef MOZ_X11
+#if defined(MOZ_X11) && (MOZ_WIDGET_GTK == 2)
 
   PRLibrary *gnomeuiLib = PR_LoadLibrary("libgnomeui-2.so.0");
   if (!gnomeuiLib)
     return NS_OK;
 
   PRLibrary *gnomeLib = PR_LoadLibrary("libgnome-2.so.0");
   if (!gnomeLib) {
     PR_UnloadLibrary(gnomeuiLib);
@@ -477,46 +479,47 @@ nsNativeAppSupportUnix::Start(bool *aRet
     (_gnome_program_get_fn)PR_FindFunctionSymbol(gnomeLib, "gnome_program_get"); 
  _libgnomeui_module_info_get_fn libgnomeui_module_info_get = (_libgnomeui_module_info_get_fn)PR_FindFunctionSymbol(gnomeuiLib, "libgnomeui_module_info_get");
   if (!gnome_program_init || !gnome_program_get || !libgnomeui_module_info_get) {
     PR_UnloadLibrary(gnomeuiLib);
     PR_UnloadLibrary(gnomeLib);
     return NS_OK;
   }
 
-#endif /* MOZ_X11 */
+#endif /* MOZ_X11 && (MOZ_WIDGET_GTK == 2) */
 
 #ifdef ACCESSIBILITY
   // We will load gail, atk-bridge by ourself later
   // We can't run atk-bridge init here, because gail get the control
   // Set GNOME_ACCESSIBILITY to 0 can avoid this
   static const char *accEnv = "GNOME_ACCESSIBILITY";
   const char *accOldValue = getenv(accEnv);
   setenv(accEnv, "0", 1);
 #endif
 
-#ifdef MOZ_X11
+#if defined(MOZ_X11) && (MOZ_WIDGET_GTK == 2)
   if (!gnome_program_get()) {
     gnome_program_init("Gecko", "1.0", libgnomeui_module_info_get(), gArgc, gArgv, NULL);
   }
-#endif /* MOZ_X11 */
+#endif /* MOZ_X11 && (MOZ_WIDGET_GTK == 2) */
 
 #ifdef ACCESSIBILITY
   if (accOldValue) { 
     setenv(accEnv, accOldValue, 1);
   } else {
     unsetenv(accEnv);
   }
 #endif
 
   // Careful! These libraries cannot be unloaded after this point because
   // gnome_program_init causes atexit handlers to be registered. Strange
   // crashes will occur if these libraries are unloaded.
 
-#ifdef MOZ_X11
+  // TODO GTK3 - see Bug 694570 - Stop using libgnome and libgnomeui on Linux
+#if defined(MOZ_X11) && (MOZ_WIDGET_GTK == 2)
   gnome_client_set_restart_command = (_gnome_client_set_restart_command_fn)
     PR_FindFunctionSymbol(gnomeuiLib, "gnome_client_set_restart_command");
 
   _gnome_master_client_fn gnome_master_client = (_gnome_master_client_fn)
     PR_FindFunctionSymbol(gnomeuiLib, "gnome_master_client");
 
   GnomeClient *client = gnome_master_client();
   g_signal_connect(client, "save-yourself", G_CALLBACK(save_yourself_cb), NULL);
@@ -549,17 +552,17 @@ nsNativeAppSupportUnix::Start(bool *aRet
       executablePath->GetNativePath(path);
       argv1 = (char*)(path.get());
     }
   }
 
   if (argv1) {
     gnome_client_set_restart_command(client, 1, &argv1);
   }
-#endif /* MOZ_X11 */
+#endif /* MOZ_X11 && (MOZ_WIDGET_GTK == 2) */
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsNativeAppSupportUnix::Stop(bool *aResult)
 {
   NS_ENSURE_ARG(aResult);
--- a/toolkit/xre/nsSigHandlers.cpp
+++ b/toolkit/xre/nsSigHandlers.cpp
@@ -96,22 +96,22 @@ child_ah_crap_handler(int signum)
 {
   if (!getenv("MOZ_DONT_UNBLOCK_PARENT_ON_CHILD_CRASH"))
     close(kClientChannelFd);
   ah_crap_handler(signum);
 }
 
 #endif // CRAWL_STACK_ON_SIGSEGV
 
-#ifdef MOZ_WIDGET_GTK2
+#ifdef MOZ_WIDGET_GTK
 // Need this include for version test below.
 #include <glib.h>
 #endif
 
-#if defined(MOZ_WIDGET_GTK2) && (GLIB_MAJOR_VERSION > 2 || (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION >= 6))
+#if defined(MOZ_WIDGET_GTK) && (GLIB_MAJOR_VERSION > 2 || (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION >= 6))
 
 static GLogFunc orig_log_func = NULL;
 
 extern "C" {
 static void
 my_glib_log_func(const gchar *log_domain, GLogLevelFlags log_level,
                  const gchar *message, gpointer user_data);
 }
@@ -277,17 +277,17 @@ void InstallSignalHandlers(const char *P
 #if defined(DEBUG)
 	    	if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
 		    printf("File descriptors set to %d\n", rl.rlim_cur);
 #endif //DEBUG
 	    }
     }
 #endif //SOLARIS
 
-#if defined(MOZ_WIDGET_GTK2) && (GLIB_MAJOR_VERSION > 2 || (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION >= 6))
+#if defined(MOZ_WIDGET_GTK) && (GLIB_MAJOR_VERSION > 2 || (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION >= 6))
   const char *assertString = PR_GetEnv("XPCOM_DEBUG_BREAK");
   if (assertString &&
       (!strcmp(assertString, "suspend") ||
        !strcmp(assertString, "stack") ||
        !strcmp(assertString, "abort") ||
        !strcmp(assertString, "trap") ||
        !strcmp(assertString, "break"))) {
     // Override the default glib logging function so we get stacks for it too.