* store the file name for later re-use
[simple-launcher] / launcher-item.h
1 // This file is a part of Simple Launcher
2 //
3 // Copyright (C) 2006, Mikhail Sobolev
4 //
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.
8 //
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
12 // more details.
13 //
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
17
18 #ifndef __LAUNCHER_ITEM_H__
19 #define __LAUNCHER_ITEM_H__
20
21 #include <vector>
22 #include <string>
23
24 #include <gdk-pixbuf/gdk-pixbuf.h>
25 #include <gtk/gtkicontheme.h>
26
27 class LauncherItem {
28 public:
29   LauncherItem();
30   virtual ~LauncherItem();
31
32   bool load(const std::string&);
33
34   GdkPixbuf *getIcon(int icon_size) const;
35
36   const std::string& getFileName() const { return myFileName; }
37   const std::string& getName() const { return myName; }
38   const std::string& getComment() const { return myComment; }
39   const std::string& getService() const { return myService; }
40
41   bool isEnabled(void) const { return myEnabled; }
42
43   void enable() { myEnabled = checkSanity(); }
44   void disable() { myEnabled = false; }
45   void toggle() {
46     if (myEnabled) {
47       disable();
48     } else {
49       enable();
50     }
51   }
52
53 private:
54   bool checkSanity(void) { return !(myName.empty() || myIcon.empty() || myService.empty()); }
55
56 private:
57   std::string myFileName, myName, myComment, myIcon, myService;
58   bool myEnabled;
59
60   static GtkIconTheme *ourTheme;
61 };
62
63 typedef std::vector<std::pair<std::string, LauncherItem *> > LauncherItems;
64
65 #endif
66
67 // vim:ts=2:sw=2:et