GHIPlatformIsSupported(void)
{
const char *desktopEnv = Xdg_DetectDesktopEnv();
- return (g_strcmp0(desktopEnv, "GNOME") == 0)
- || (g_strcmp0(desktopEnv, "KDE") == 0);
+ Bool supported = (g_strcmp0(desktopEnv, "GNOME") == 0) ||
+ (g_strcmp0(desktopEnv, "KDE") == 0);
+ if (!supported) {
+ g_message("GHI not available under unsupported desktop environment %s\n",
+ desktopEnv ? desktopEnv : "(nil)");
+ }
+ return supported;
}
Gtk::Main::init_gtkmm_internals();
+ if (!GHIPlatformIsSupported()) {
+ /*
+ * Don't bother allocating resources if running under an unsupported
+ * desktop environment.
+ */
+ return NULL;
+ }
+
ghip = (GHIPlatform *) Util_SafeCalloc(1, sizeof *ghip);
ghip->appsByWindowExecutable =
g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
}
desktopEnv = Xdg_DetectDesktopEnv();
+ ASSERT(desktopEnv); // Asserting based on GHIPlatformIsSupported check above.
g_desktop_app_info_set_desktop_env(desktopEnv);
#ifdef REDIST_GMENU
return;
}
+#ifdef REDIST_GMENU
+ delete ghip->menuItemManager;
+#endif
g_hash_table_destroy(ghip->appsByWindowExecutable);
free(ghip);
}
--- /dev/null
+/*********************************************************
+ * Copyright (C) 2011 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *********************************************************/
+
+/*
+ * unityPluginPosix.cpp --
+ *
+ * POSIX subclass of UnityPlugin interface.
+ */
+
+
+#include "unityPluginPosix.h"
+
+
+extern "C" {
+#include <glib-object.h>
+
+#include "vmware/tools/desktopevents.h"
+#if defined(OPEN_VM_TOOLS)
+ #include "unitylib/unity.h"
+#else
+ #include "unity.h"
+#endif // OPEN_VM_TOOLS
+}
+
+
+namespace vmware {
+namespace tools {
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * UnityPluginPosix::UnityPluginPosix --
+ *
+ * Constructor.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+UnityPluginPosix::UnityPluginPosix()
+ : UnityPlugin(),
+ mCtx(NULL)
+{
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * UnityPluginPosix::~UnityPluginPosix --
+ *
+ * Destructor.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+UnityPluginPosix::~UnityPluginPosix()
+{
+ if (mCtx) {
+ for (std::map<const char*, gulong>::iterator i = mSignalIDs.begin();
+ i != mSignalIDs.end();
+ ++i) {
+ g_signal_handler_disconnect(mCtx->serviceObj, i->second);
+ }
+ }
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * UnityPluginPosix::Initialize --
+ *
+ * Initialize UnityPlugin base class and connect to X Session Manager
+ * GLib signals.
+ *
+ * Results:
+ * TRUE on success, FALSE otherwise.
+ *
+ * Side effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+gboolean
+UnityPluginPosix::Initialize(ToolsAppCtx* ctx) // IN
+{
+ if (UnityPlugin::Initialize(ctx)) {
+ mCtx = ctx;
+ mSignalIDs[TOOLS_CORE_SIG_XSM_DIE] =
+ g_signal_connect(ctx->serviceObj, TOOLS_CORE_SIG_XSM_DIE,
+ G_CALLBACK(XSMDieCb), static_cast<gpointer>(this));
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * UnityPluginPosix::OnXSMEvent --
+ *
+ * X Session Management event handler. Exits Unity upon notice of session
+ * termination.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * May trigger Unity exit.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+void
+UnityPluginPosix::OnXSMDie()
+{
+ if (Unity_IsActive()) {
+ Unity_Exit();
+ }
+}
+
+
+/*
+ ******************************************************************************
+ * BEGIN Static member functions
+ */
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * UnityPluginPosix::XSMDieCb --
+ *
+ * Thunk between XSM "die" OnXSMDie.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * See OnXSMDie.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+void
+UnityPluginPosix::XSMDieCb(GObject* obj, // UNUSED
+ ToolsAppCtx* ctx, // UNUSED
+ gpointer cbData) // IN: UnityPluginPosix*
+{
+ UnityPluginPosix* unityPlugin = static_cast<UnityPluginPosix*>(cbData);
+ unityPlugin->OnXSMDie();
+}
+
+
+/*
+ * END Static member functions
+ ******************************************************************************
+ */
+
+
+} // namespace tools
+} // namespace vmware
--- /dev/null
+/*********************************************************
+ * Copyright (C) 2011 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *********************************************************/
+
+/*
+ * unityPluginPosix.h --
+ *
+ * POSIX subclass of UnityPlugin interface.
+ */
+
+#ifndef UNITY_PLUGIN_POSIX_H
+#define UNITY_PLUGIN_POSIX_H
+
+#include <map>
+
+#include "unityPlugin.h"
+
+extern "C" {
+#include <glib-object.h>
+}
+
+
+namespace vmware {
+namespace tools {
+
+class UnityPluginPosix
+ : public UnityPlugin
+{
+public:
+ UnityPluginPosix();
+ virtual ~UnityPluginPosix();
+
+ gboolean Initialize(ToolsAppCtx* ctx);
+
+private:
+ static void XSMDieCb(GObject*, ToolsAppCtx*, gpointer);
+ void OnXSMDie();
+
+ ToolsAppCtx* mCtx;
+ std::map<const char*, gulong> mSignalIDs;
+};
+
+
+} // namespace tools
+} // namespace vmware
+
+#endif // UNITY_PLUGIN_POSIX_H