Back to index

unity  6.0.0
SimpleLauncherIcon.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2010 Canonical Ltd
00004  *
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 3 as
00007  * published by the Free Software Foundation.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  *
00017  * Authored by: Jason Smith <jason.smith@canonical.com>
00018  */
00019 
00020 #ifndef UNITYSHELL_SIMPLELAUNCHERICON_H
00021 #define UNITYSHELL_SIMPLELAUNCHERICON_H
00022 
00023 #include "LauncherIcon.h"
00024 
00025 namespace unity
00026 {
00027 namespace launcher
00028 {
00029 
00030 class Launcher;
00031 
00032 class SimpleLauncherIcon : public LauncherIcon
00033 {
00034   NUX_DECLARE_OBJECT_TYPE(SimpleLauncherIcon, LauncherIcon);
00035 public:
00036   SimpleLauncherIcon();
00037   virtual ~SimpleLauncherIcon();
00038 
00039   // override
00040   nux::BaseTexture* GetTextureForSize(int size);
00041 
00042   // Properties
00043   nux::Property<std::string> icon_name;
00044 
00045   // Signals
00046   sigc::signal<void> activate;
00047 
00048 protected:
00049   std::string GetName() const;
00050   void AddProperties(GVariantBuilder* builder);
00051 
00052   virtual void OnMouseDown(int button, int monitor, unsigned long key_flags = 0);
00053   virtual void OnMouseUp(int button, int monitor, unsigned long key_flags = 0);
00054   virtual void OnMouseClick(int button, int monitor, unsigned long key_flags = 0);
00055   virtual void OnMouseEnter(int monitor);
00056   virtual void OnMouseLeave(int monitor);
00057   virtual void ActivateLauncherIcon(ActionArg arg);
00058 
00059 private:
00060   void ReloadIcon();
00061   static void OnIconThemeChanged(GtkIconTheme* icon_theme, gpointer data);
00062   bool SetIconName(std::string& target, std::string const& value);
00063 
00064 private:
00065   guint32 theme_changed_id_;
00066 
00067   std::map<int, nux::BaseTexture*> texture_map;
00068   int last_size_;
00069 };
00070 
00071 }
00072 }
00073 
00074 #endif // SIMPLELAUNCHERICON_H
00075