1 // This file is a part of Simple Launcher
3 // Copyright (C) 2006, 2007, Mikhail Sobolev
5 // Simple Launcher is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU General Public License version 2 as published by
7 // the Free Software Foundation.
9 // This program is distributed in the hope that it will be useful, but WITHOUT
10 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 // You should have received a copy of the GNU General Public License along with
15 // this program; if not, write to the Free Software Foundation, Inc., 51
16 // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #include "ApplicationItem.h"
20 static ApplicationItemFactory factory;
22 const std::string& ApplicationItemFactory::factoryName() const {
23 const std::string& NAME = "ApplicationItem";
28 BasicItem *ApplicationItemFactory::createItem(const std::string& itemID) const {
29 return new ApplicationItem(itemID);
32 ApplicationItem::ApplicationItem(const std::string& itemID): BasicItem(factory.factoryName(), itemID) {
35 ApplicationItem::~ApplicationItem() {
38 bool ApplicationItem::load() {
39 GKeyFileWrapper key_file;
42 if (!key_file.load(myID)) {
46 if (key_file.getString(DESKTOP_ENTRY_GROUP, DESKTOP_ENTRY_TYPE_FIELD) != "Application") {
50 myName = key_file.getLocaleString(DESKTOP_ENTRY_GROUP, DESKTOP_ENTRY_NAME_FIELD);
51 myComment = key_file.getLocaleString(DESKTOP_ENTRY_GROUP, DESKTOP_ENTRY_COMMENT_FIELD);
52 myIcon = key_file.getString(DESKTOP_ENTRY_GROUP, DESKTOP_ENTRY_ICON_FIELD);
53 myService = key_file.getString(DESKTOP_ENTRY_GROUP, DESKTOP_ENTRY_SERVICE_FIELD);
54 myExec = key_file.getString(DESKTOP_ENTRY_GROUP, DESKTOP_ENTRY_EXEC_FIELD);
55 myTextDomain = key_file.getString(DESKTOP_ENTRY_GROUP, DESKTOP_ENTRY_TEXT_DOMAIN);
60 return (myEnabled = checkSanity());
63 void ApplicationItem::activate(osso_context_t *context) {
66 if (myService.empty() || !(result = osso_rpc_run_with_defaults(context, myService.c_str(), "top_application", NULL, DBUS_TYPE_INVALID) == OSSO_OK)) {
67 runApplication(getExec());