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 #ifndef __LAUNCHER_ITEM_H__
19 #define __LAUNCHER_ITEM_H__
25 #include <gdk-pixbuf/gdk-pixbuf.h>
26 #include <gtk/gtkicontheme.h>
31 virtual ~LauncherItem();
33 bool load(const std::string&);
35 GdkPixbuf *getIcon(int icon_size) const;
37 const std::string& getFileName() const { return myFileName; }
38 const std::string& getName() const { return myName; }
39 const std::string& getComment() const { return myComment; }
40 const std::string& getService() const { return myService; }
42 bool isEnabled(void) const { return myEnabled; }
44 void enable() { myEnabled = checkSanity(); }
45 void disable() { myEnabled = false; }
55 bool checkSanity(void) { return !(myName.empty() || myIcon.empty() || myService.empty()); }
58 std::string myFileName, myName, myComment, myIcon, myService;
61 static GtkIconTheme *ourTheme;
65 typedef std::vector<std::string> Names;
66 typedef std::map<std::string, LauncherItem *> Items;
71 bool exists(const std::string& name) {
72 return myNames.find(name) != myNames.end();
75 size_t size() { return myNames.size(); }
77 LauncherItem *operator[](int index) {
78 return myItems[myNames[index]];
81 std::string& name(int index) {
82 return myNames[index];
85 void add(const std::string& name, LauncherItem *item) {
86 myNames.push_back(name);
90 void swap(size_t i1, size_t i2) {
91 std::swap(myNames[i1], myNames[i2]);
95 for (Items::iterator it = myItems.begin(); it != myItems.end(); ++it) {
96 if (it->second != NULL) {