Commits

Ilya Skriblovsky committed 6bebf4c Draft

Makefile option to disable Launcher

  • Participants
  • Parent commits c3c7f50

Comments (0)

Files changed (8)

 DBus * DBus::_instance = 0;
 
 
+#ifdef LAUNCHER
 DBus::DBus(XEventLoop *eventLoop, TeleWindow *teleWindow, LauncherWindow *launcherWindow)
+#else
+DBus::DBus(XEventLoop *eventLoop, TeleWindow *teleWindow)
+#endif
 {
     _instance = this;
 
     _teleWindow = teleWindow;
-    _launcherWindow = launcherWindow;
+
+    #ifdef LAUNCHER
+        _launcherWindow = launcherWindow;
+    #endif
 
 
     DBusError error;
         &_telescopeVTable, this);
 
 
-    _launcherVTable.unregister_function = (DBusObjectPathUnregisterFunction)launcher_unregister;
-    _launcherVTable.message_function = (DBusObjectPathMessageFunction)launcher_message;
-    dbus_connection_register_object_path(_conn, "/Launcher",
-        &_launcherVTable, this);
+    #ifdef LAUNCHER
+        _launcherVTable.unregister_function = (DBusObjectPathUnregisterFunction)launcher_unregister;
+        _launcherVTable.message_function = (DBusObjectPathMessageFunction)launcher_message;
+        dbus_connection_register_object_path(_conn, "/Launcher",
+            &_launcherVTable, this);
+    #endif
 
 
 
         self->_teleWindow->hide();
     }
 
-    XFlush(self->_launcherWindow->display());
+    XFlush(self->_teleWindow->display());
 
     return DBUS_HANDLER_RESULT_HANDLED;
 }
 
 
+#ifdef LAUNCHER
+
 void DBus::launcher_unregister(DBusConnection *conn, DBus *self)
 {
 }
     return DBUS_HANDLER_RESULT_HANDLED;
 }
 
+#endif
+
 
 #endif
 
 class XEventLoop;
 class TeleWindow;
-class LauncherWindow;
+
+#ifdef LAUNCHER
+    class LauncherWindow;
+#endif
 
 class DBus: public XIdleTask
 {
 
         XEventLoop *_eventLoop;
         TeleWindow *_teleWindow;
-        LauncherWindow *_launcherWindow;
 
         DBusConnection *_conn;
 
         DBusObjectPathVTable _telescopeVTable;
-        DBusObjectPathVTable _launcherVTable;
 
         static void telescope_unregister(
             DBusConnection *conn,
             DBus *self
         );
 
-        static void launcher_unregister(
-            DBusConnection *conn,
-            DBus *self
-        );
-        static DBusHandlerResult launcher_message(
-            DBusConnection *conn,
-            DBusMessage *msg,
-            DBus *self
-        );
+        #ifdef LAUNCHER
+            LauncherWindow *_launcherWindow;
+            DBusObjectPathVTable _launcherVTable;
+
+            static void launcher_unregister(
+                DBusConnection *conn,
+                DBus *self
+            );
+            static DBusHandlerResult launcher_message(
+                DBusConnection *conn,
+                DBusMessage *msg,
+                DBus *self
+            );
+        #endif
+
 
 
         static void sendDBusMessageToWindow(Display *dpy, Window window, DBusMessageType msg);
         void onIdle();
 
     public:
-        DBus(XEventLoop *eventLoop, TeleWindow *teleWindow, LauncherWindow *launcherWindow);
+        #ifdef LAUNCHER
+            DBus(XEventLoop *eventLoop, TeleWindow *teleWindow, LauncherWindow *launcherWindow);
+        #else
+            DBus(XEventLoop *eventLoop, TeleWindow *teleWindow);
+        #endif
+
         virtual ~DBus();
 
         static DBus * instance() { return _instance; }
 #include <X11/Xlib.h>
 
 #include "TeleWindow.h"
-#include "LauncherWindow.h"
 #include "XTools.h"
 #include "Settings.h"
 #include "Resources.h"
 #include "DBus.h"
 
-#include "LauncherWindow.h"
-#include "SectionList.h"
-#include "MenuReader.h"
+#include "XEventLoop.h"
 
-#include "XEventLoop.h"
+
+#ifdef LAUNCHER
+    #include "LauncherWindow.h"
+    #include "SectionList.h"
+    #include "MenuReader.h"
+#endif
 
 
 
     Resources * resources = new Resources(dpy);
 
 
-    MenuReader *menuReader = new MenuReader(dpy);
-
-    // read the hildon application menu
-    //SectionList * list = MenuReader::getInstance()->processMenu();
-//    if (list == NULL)
-//    {
-//      fprintf(stderr, "Cannot read the menu configuration");
-//      return 1;
-//    }
-
     XEventLoop *eventLoop = new XEventLoop(dpy);
 
 
     TeleWindow *teleWindow = new TeleWindow(dpy);
-    LauncherWindow *launcherWindow = 0;
-    if (! settings->disableLauncher())
-        launcherWindow = new LauncherWindow(dpy/*, list*/);
 
-    DBus *dbus = new DBus(eventLoop, teleWindow, launcherWindow);
+    #ifdef LAUNCHER
+        MenuReader *menuReader = new MenuReader(dpy);
+        LauncherWindow *launcherWindow = 0;
+        if (! settings->disableLauncher())
+            launcherWindow = new LauncherWindow(dpy/*, list*/);
+    #endif
+
+    #ifdef LAUNCHER
+        DBus *dbus = new DBus(eventLoop, teleWindow, launcherWindow);
+    #else
+        DBus *dbus = new DBus(eventLoop, teleWindow);
+    #endif
+
 
     eventLoop->eventLoop();
 
     delete dbus;
 
     delete teleWindow;
-    delete launcherWindow;
+
+    #ifdef LAUNCHER
+        delete launcherWindow;
+        delete menuReader;
+    #endif
+
     delete resources;
     delete settings;
-    delete menuReader;
 
     XCloseDisplay(dpy);
 }
 #DEFINES = -DKDE -DDBUS
 DEFINES = -DMAEMO4 -DDBUS
 
+LAUNCHER = 1
+
 SOURCES = TeleWindow.cpp    \
           Main.cpp          \
           XTools.cpp        \
           Mappings.cpp      \
           Resources.cpp     \
           DBus.cpp          \
-          MenuReader.cpp    \
-          LauncherWindow.cpp\
-          SectionList.cpp   \
-          Section.cpp       \
-          Application.cpp   \
           XEventLoop.cpp    \
           Image.cpp
 
 
+ifeq ($(LAUNCHER),1)
+    DEFINES += -DLAUNCHER
+
+    SOURCES += \
+        MenuReader.cpp       \
+        LauncherWindow.cpp   \
+        SectionList.cpp      \
+        Section.cpp          \
+        Application.cpp
+
+    SHAREFILES += \
+         text-background.png        \
+         indicator.png              \
+         navigation.png             \
+         transparent.png            \
+         panel-icons/panel.png      \
+         panel-icons/panel-focus-left.png   \
+         panel-icons/panel-focus-right.png  \
+         panel-icons/panel-focus-middle.png \
+         category-icons
+endif
+
+
 DEPS = x11 xcomposite xdamage xrender imlib2 xft dbus-1 glib-2.0
 
 SHAREFILES = header-left.png    \
              header-right-selected.png  \
              header-middle-selected.png \
              broken-pattern.png         \
-             install-notice.txt         \
-             text-background.png        \
-             indicator.png              \
-             navigation.png             \
-             transparent.png            \
-             panel-icons/panel.png      \
-             panel-icons/panel-focus-left.png   \
-             panel-icons/panel-focus-right.png  \
-             panel-icons/panel-focus-middle.png \
-             category-icons
+             install-notice.txt
 
 CONFFILES = telescope.conf telescope.keys
 

File Resources.cpp

     printf("Loading background from '%s'\n", Settings::instance()->backgroundFilename());
     printf("Background mode: %d\n", Settings::instance()->backgroundMode());
 
+    imlib_context_set_display(_dpy);
+
     int bgXpos = 0;
     int bgYpos = 0;
     Imlib_Image background = imlib_load_image(Settings::instance()->backgroundFilename());

File Settings.cpp

     _hotKey = strdup("F5");
 
 
-    _disableLauncher = false;
+    #ifdef LAUNCHER
+        _disableLauncher = false;
+    #endif
 
     _categoryIconsDir = strdup("/usr/share/telescope/category-icons/");
 
         free(_brokenPatternFilename);
         _brokenPatternFilename = strdup(value);
     }
-    else if (strcmp(key, "launcher.text.background") == 0)
-    {
-        free(_textBackgroundFilename);
-        _textBackgroundFilename = strdup(value);
-    }
-    else if (strcmp(key, "launcher.panel.background.filename") == 0)
-    {
-        free(_panelBackgroundFilename);
-        _panelBackgroundFilename = strdup(value);
-    }
-    else if (strcmp(key, "launcher.panel.focus.left.filename") == 0)
-    {
-        free(_panelFocusLeftFilename);
-        _panelFocusLeftFilename = strdup(value);
-    }
-    else if (strcmp(key, "launcher.panel.focus.right.filename") == 0)
-    {
-        free(_panelFocusRightFilename);
-        _panelFocusRightFilename = strdup(value);
-    }
-    else if (strcmp(key, "launcher.panel.focus.middle.filename") == 0)
-    {
-        free(_panelFocusMiddleFilename);
-        _panelFocusMiddleFilename = strdup(value);
-    }
+    #ifdef LAUNCHER
+        else if (strcmp(key, "launcher.text.background") == 0)
+        {
+            free(_textBackgroundFilename);
+            _textBackgroundFilename = strdup(value);
+        }
+        else if (strcmp(key, "launcher.panel.background.filename") == 0)
+        {
+            free(_panelBackgroundFilename);
+            _panelBackgroundFilename = strdup(value);
+        }
+        else if (strcmp(key, "launcher.panel.focus.left.filename") == 0)
+        {
+            free(_panelFocusLeftFilename);
+            _panelFocusLeftFilename = strdup(value);
+        }
+        else if (strcmp(key, "launcher.panel.focus.right.filename") == 0)
+        {
+            free(_panelFocusRightFilename);
+            _panelFocusRightFilename = strdup(value);
+        }
+        else if (strcmp(key, "launcher.panel.focus.middle.filename") == 0)
+        {
+            free(_panelFocusMiddleFilename);
+            _panelFocusMiddleFilename = strdup(value);
+        }
+        else if (strcmp(key, "launcher.disable") == 0)
+            _disableLauncher = parseBool(value);
+        else if (strcmp(key, "launcher.categories.iconsdir") == 0)
+        {
+            free(_categoryIconsDir);
+            _categoryIconsDir = strdup(value);
+        }
+    #endif
     else if (strcmp(key, "border.width") == 0)
         _borderWidth = atoi(value);
     else if (strcmp(key, "text.leftMargin") == 0)
         free(_hotKey);
         _hotKey = strdup(value);
     }
-    else if (strcmp(key, "launcher.disable") == 0)
-        _disableLauncher = parseBool(value);
-    else if (strcmp(key, "launcher.categories.iconsdir") == 0)
-    {
-        free(_categoryIconsDir);
-        _categoryIconsDir = strdup(value);
-    }
 }
 
 
         bool _showDesktopByIconify;
 
 
-        bool _disableLauncher;
+        #ifdef LAUNCHER
+            bool _disableLauncher;
+        #endif
 
 
         char *_categoryIconsDir;
         const char *hotKey() { return _hotKey; }
 
 
-        bool disableLauncher() { return _disableLauncher; }
+        bool disableLauncher()
+        {
+            #ifdef LAUNCHER
+                return _disableLauncher;
+            #else
+                return true;
+            #endif
+        }
 
 
         const char *categoryIconsDir() { return _categoryIconsDir; }

File TeleWindow.cpp

 
 #include "XEventLoop.h"
 
-#include "LauncherWindow.h"
+#ifdef LAUNCHER
+    #include "LauncherWindow.h"
+#endif
 
 
 TeleWindow::TeleWindow(Display *dpy)
 #endif
 
 
-//    if (_activeThumbnail)
-//        animate(_activeThumbnail, true);
+
+#ifdef LAUNCHER
 
     if (LauncherWindow::instance() && LauncherWindow::instance()->shown())
     {
         LauncherWindow::instance()->hide();
     }
 
+#endif
+
 
     return _shown;
 }
 
     if (! _shown)
     {
-        if (! show())
-            if (! Settings::instance()->disableLauncher())
-                LauncherWindow::instance()->show();
+        #ifdef LAUNCHER
+            if (! show())
+                if (! Settings::instance()->disableLauncher())
+                    LauncherWindow::instance()->show();
+        #endif
     }
     else
     {
             _mappings.handleEvent(this, Mapping::Press, _hotKeyCode);
         else
         {
-            LauncherWindow::instance()->show();
-            XTools::switchToWindow(LauncherWindow::instance()->window());
-            LauncherWindow::instance()->paint();
-            XFlush(_dpy);
-            hide();
+            #ifdef LAUNCHER
+                LauncherWindow::instance()->show();
+                XTools::switchToWindow(LauncherWindow::instance()->window());
+                LauncherWindow::instance()->paint();
+                XFlush(_dpy);
+                hide();
+            #endif
         }
     }
 }