Back to index

unity  6.0.0
BamfLauncherIcon.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2010-2012 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  *              Marco Trevisan (TreviƱo) <3v1n0@ubuntu.com>
00019  */
00020 
00021 #ifndef BAMFLAUNCHERICON_H
00022 #define BAMFLAUNCHERICON_H
00023 
00024 #include <UnityCore/GLibSignal.h>
00025 #include <UnityCore/GLibWrapper.h>
00026 
00027 #include <libbamf/libbamf.h>
00028 #include <libindicator/indicator-desktop-shortcuts.h>
00029 
00030 #include "SimpleLauncherIcon.h"
00031 
00032 namespace unity
00033 {
00034 namespace launcher
00035 {
00036 
00037 extern unsigned int ColorStrToARGB(const char *str);
00038 
00039 class Launcher;
00040 
00041 class BamfLauncherIcon : public SimpleLauncherIcon
00042 {
00043   NUX_DECLARE_OBJECT_TYPE(BamfLauncherIcon, SimpleLauncherIcon);
00044 public:
00045   BamfLauncherIcon(BamfApplication* app);
00046   virtual ~BamfLauncherIcon();
00047 
00048   virtual void ActivateLauncherIcon(ActionArg arg);
00049 
00050   std::string DesktopFile();
00051 
00052   bool IsSticky() const;
00053   bool IsVisible() const;
00054   bool IsActive() const;
00055   bool IsRunning() const;
00056   bool IsUrgent() const;
00057 
00058   void Quit();
00059   void Stick(bool save = true);
00060   void UnStick();
00061 
00062   virtual bool ShowInSwitcher(bool current);
00063   virtual unsigned long long SwitcherPriority();
00064 
00065   virtual nux::Color BackgroundColor() const;
00066 
00067   std::vector<Window> Windows();
00068   std::vector<Window> WindowsOnViewport();
00069   std::vector<Window> WindowsForMonitor(int monitor);
00070   std::string NameForWindow(Window window);
00071 
00072 protected:
00073   void Remove();
00074   void UpdateIconGeometries(std::vector<nux::Point3> center);
00075   void OnCenterStabilized(std::vector<nux::Point3> center);
00076   void AddProperties(GVariantBuilder* builder);
00077   void OnAcceptDrop(DndData const& dnd_data);
00078   void OnDndEnter();
00079   void OnDndHovered();
00080   void OnDndLeave();
00081   void OpenInstanceLauncherIcon(ActionArg arg);
00082   void ToggleSticky();
00083 
00084   bool OnShouldHighlightOnDrag(DndData const& dnd_data);
00085   nux::DndAction OnQueryAcceptDrop(DndData const& dnd_data);
00086 
00087   std::list<DbusmenuMenuitem*> GetMenus();
00088   std::set<std::string> ValidateUrisForLaunch(DndData const& dnd_data);
00089 
00090   std::string GetRemoteUri();
00091   std::string BamfName() const;
00092 
00093   bool HandlesSpread() { return true; }
00094   std::string GetName() const;
00095 
00096 private:
00097   typedef unsigned long int WindowFilterMask;
00098   enum WindowFilter
00099   {
00100     MAPPED = (1 << 0),
00101     USER_VISIBLE = (1 << 1),
00102     ON_CURRENT_DESKTOP = (1 << 2),
00103     ON_ALL_MONITORS = (1 << 3),
00104   };
00105 
00106   void EnsureWindowState();
00107   void EnsureMenuItemsReady();
00108   void UpdateBackgroundColor();
00109   void UpdateDesktopFile();
00110   void UpdateMenus();
00111   void UpdateDesktopQuickList();
00112   void FillSupportedTypes();
00113 
00114   void OpenInstanceWithUris(std::set<std::string> uris);
00115   void Focus(ActionArg arg);
00116   bool Spread(bool current_desktop, int state, bool force);
00117 
00118   void OnWindowMinimized(guint32 xid);
00119   void OnWindowMoved(guint32 xid);
00120 
00121   bool OwnsWindow(Window w) const;
00122 
00123   std::vector<Window> GetWindows(WindowFilterMask filter = 0, int monitor = -1);
00124   const std::set<std::string>& GetSupportedTypes();
00125   std::string GetDesktopID();
00126 
00127   glib::Object<BamfApplication> _bamf_app;
00128   bool _supported_types_filled;
00129 
00130   std::string _remote_uri;
00131   std::string _desktop_file;
00132   std::set<std::string> _supported_types;
00133   std::map<std::string, glib::Object<DbusmenuClient>> _menu_clients;
00134   std::map<std::string, glib::Object<DbusmenuMenuitem>> _menu_items;
00135   std::map<std::string, glib::Object<DbusmenuMenuitem>> _menu_items_extra;
00136   glib::Object<IndicatorDesktopShortcuts> _desktop_shortcuts;
00137   glib::Object<DbusmenuMenuitem> _menu_desktop_shortcuts;
00138   glib::Object<GFileMonitor> _desktop_file_monitor;
00139   glib::SignalManager _gsignals;
00140 
00141   bool use_custom_bg_color_;
00142   nux::Color bg_color_;
00143 };
00144 
00145 }
00146 }
00147 
00148 #endif // BAMFLAUNCHERICON_H