tests: test test1
-$(TARGET): simple-launcher.o launchable-item.o launcher-item.o sla-list.o
+$(TARGET): simple-launcher.o launchable-item.o launcher-item.o sla-list.o utils.o
$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
test: test.o launcher-item.o
simple-launcher (0.9.3) unstable; urgency=low
* the config file can now be backed up
+ * enable activation of applications that do not have d-bus service
- -- Mikhail Sobolev <mss@mawhrin.net> Sat, 24 Mar 2007 12:32:51 +0200
+ -- Mikhail Sobolev <mss@mawhrin.net> Sat, 24 Mar 2007 21:11:54 +0200
simple-launcher (0.9.2) unstable; urgency=low
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "launchable-item.h"
+#include "utils.h"
bool LaunchableItem::activate(osso_context_t *context) {
- return osso_application_top(context, getService().c_str(), NULL) == OSSO_OK;
+ bool result = false;
+
+ if (getService().empty() || !(result = osso_application_top(context, getService().c_str(), NULL) == OSSO_OK)) {
+ runApplication(getExec());
+ return true;
+ } else {
+ return result;
+ }
}
// vim:ts=2:sw=2:et
*DESKTOP_ENTRY_ICON_FIELD = "Icon",
*DESKTOP_ENTRY_NAME_FIELD = "Name",
*DESKTOP_ENTRY_COMMENT_FIELD = "Comment",
+ *DESKTOP_ENTRY_EXEC_FIELD = "Exec",
*DESKTOP_ENTRY_SERVICE_FIELD = "X-Osso-Service",
*DESKTOP_ENTRY_TEXT_DOMAIN = "X-Text-Domain";
myComment = key_file.getLocaleString(DESKTOP_ENTRY_GROUP, DESKTOP_ENTRY_COMMENT_FIELD);
myIcon = key_file.getString(DESKTOP_ENTRY_GROUP, DESKTOP_ENTRY_ICON_FIELD);
myService = key_file.getString(DESKTOP_ENTRY_GROUP, DESKTOP_ENTRY_SERVICE_FIELD);
+ myExec = key_file.getString(DESKTOP_ENTRY_GROUP, DESKTOP_ENTRY_EXEC_FIELD);
myTextDomain = key_file.getString(DESKTOP_ENTRY_GROUP, DESKTOP_ENTRY_TEXT_DOMAIN);
break;
std::string getName(bool translate = true) const { return translate ? translateString(myName) : myName; }
std::string getComment(bool translate = true) const { return translate ? translateString(myComment) : myComment; }
const std::string& getService() const { return myService; }
+ const std::string& getExec() const { return myExec; }
bool isEnabled(void) const { return myEnabled; }
private:
std::string translateString(const std::string& what) const;
- bool checkSanity(void) { return !(myName.empty() || myService.empty()); }
+ bool checkSanity(void) { return !myName.empty() && (!myService.empty() || !myExec.empty()); }
private:
- std::string myFileName, myName, myComment, myIcon, myService, myTextDomain;
+ std::string myFileName, myName, myComment, myIcon, myService, myExec, myTextDomain;
bool myEnabled;
static GtkIconTheme *ourTheme;
--- /dev/null
+// This file is a part of Simple Launcher
+//
+// Copyright (C) 2006, 2007, Mikhail Sobolev
+//
+// Simple Launcher is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation.
+//
+// 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 GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU 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
+
+#include <glib/gerror.h>
+#include <glib/gutils.h>
+#include <glib/gshell.h>
+#include <glib/gspawn.h>
+#include <glib/gmem.h>
+
+#include "utils.h"
+
+void runApplication(const std::string& whatToRun) {
+ if (!whatToRun.empty()) {
+ GError *error = NULL;
+ std::string::size_type pos;
+ std::string app, args;
+
+ if ((pos = whatToRun.find(' ')) != std::string::npos) {
+ app = whatToRun.substr(0, pos);
+ args = whatToRun.substr(pos);
+ } else {
+ app = whatToRun;
+ }
+
+ {
+ gchar *fullPath = g_find_program_in_path(app.c_str());
+
+ app = std::string(fullPath);
+
+ g_free(fullPath);
+ }
+
+ if (!args.empty()) {
+ app += args;
+ }
+
+ if (!app.empty()) {
+ gint argc;
+ gchar **argv;
+ GPid pid;
+
+ if (g_shell_parse_argv (app.c_str(), &argc, &argv, &error)) {
+ g_spawn_async(NULL, argv, NULL, (GSpawnFlags)0, NULL, NULL, &pid, &error);
+ }
+
+ if (error != NULL) {
+ g_error_free(error);
+ }
+ }
+ }
+}
--- /dev/null
+// This file is a part of Simple Launcher
+//
+// Copyright (C) 2006, 2007, Mikhail Sobolev
+//
+// Simple Launcher is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation.
+//
+// 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 GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU 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
+
+#ifndef __UTILS_H__
+#define __UTILS_H__
+
+#include <string>
+
+ void runApplication(const std::string& whatToRun);
+
+#endif