X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=launcher-item.h;h=3b4065e2f4eabb49a70d622c5350443a6ef16d99;hb=4c314ded72f7c0003e87084b462dc931fee432d7;hp=b5e811ecfa890d3d5d7afcff8c7c09455adea51e;hpb=b4055b89d0a9285e3dd1825b03c0b546c58dd0d2;p=simple-launcher diff --git a/launcher-item.h b/launcher-item.h index b5e811e..3b4065e 100644 --- a/launcher-item.h +++ b/launcher-item.h @@ -1,10 +1,10 @@ // This file is a part of Simple Launcher // -// Copyright (C) 2006, Mikhail Sobolev +// 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 as published by the Free -// Software Foundation; either version 2 of the License. +// 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 @@ -18,28 +18,100 @@ #ifndef __LAUNCHER_ITEM_H__ #define __LAUNCHER_ITEM_H__ +#include +#include #include +#include #include - -#include +#include class LauncherItem { public: LauncherItem(); - ~LauncherItem(); - - bool activate(osso_context_t *); + virtual ~LauncherItem(); bool load(const std::string&); GdkPixbuf *getIcon(int icon_size) const; + const std::string& getFileName() const { return myFileName; } const std::string& getName() const { return myName; } const std::string& getComment() const { return myComment; } const std::string& getService() const { return myService; } + + bool isEnabled(void) const { return myEnabled; } + + void enable() { myEnabled = checkSanity(); } + void disable() { myEnabled = false; } + void toggle() { + if (myEnabled) { + disable(); + } else { + enable(); + } + } + private: - std::string myName, myComment, myIcon, myService; + bool checkSanity(void) { return !(myName.empty() || myIcon.empty() || myService.empty()); } + +private: + std::string myFileName, myName, myComment, myIcon, myService; + bool myEnabled; + + static GtkIconTheme *ourTheme; +}; + +typedef struct LauncherItems { + typedef std::vector Names; + typedef std::map Items; + + Names myNames; + Items myItems; + + bool exists(const std::string& name) { + return std::find(myNames.begin(), myNames.end(), name) != myNames.end(); + } + + size_t size() { return myNames.size(); } + + LauncherItem *operator[](int index) { + return myItems[myNames[index]]; + } + + std::string& name(int index) { + return myNames[index]; + } + + void add(const std::string& name, LauncherItem *item) { + myNames.push_back(name); + myItems[name] = item; + } + + void swap(size_t i1, size_t i2) { + std::swap(myNames[i1], myNames[i2]); + } + + void clear() { + for (Items::iterator it = myItems.begin(); it != myItems.end(); ++it) { + if (it->second != NULL) { + delete it->second; + it->second = NULL; + } + } + + myNames.resize(0); + myItems.clear(); + } + + LauncherItems& operator=(const LauncherItems& that) { + myNames = that.myNames; + myItems = that.myItems; + + return *this; + } }; #endif + +// vim:ts=2:sw=2:et