Back to index

unity  6.0.0
AbstractLauncherIcon.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2011 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 
00021 #ifndef ABSTRACTLAUNCHERICON_H
00022 #define ABSTRACTLAUNCHERICON_H
00023 
00024 #include <Nux/Nux.h>
00025 #include <NuxCore/Property.h>
00026 #include <NuxCore/Math/MathInc.h>
00027 
00028 #include <sigc++/sigc++.h>
00029 
00030 #include <X11/Xlib.h>
00031 
00032 #include <libdbusmenu-glib/menuitem.h>
00033 
00034 #include "DndData.h"
00035 #include "unity-shared/Introspectable.h"
00036 #include "LauncherEntryRemote.h"
00037 #include "unity-shared/IconTextureSource.h"
00038 
00039 namespace unity
00040 {
00041 namespace launcher
00042 {
00043 
00044 class ActionArg
00045 {
00046 public:
00047   enum Source
00048   {
00049     LAUNCHER,
00050     SWITCHER,
00051     OTHER,
00052   };
00053 
00054   ActionArg()
00055     : source(OTHER)
00056     , button(0)
00057     , target(0)
00058     , monitor(-1)
00059   {
00060   }
00061 
00062   ActionArg(Source source, int button, Window target = 0, int monitor = -1)
00063     : source(source)
00064     , button(button)
00065     , target(target)
00066     , monitor(monitor)
00067   {
00068   }
00069 
00070   Source source;
00071   int button;
00072   Window target;
00073   int monitor;
00074 };
00075 
00076 class AbstractLauncherIcon : public ui::IconTextureSource, public debug::Introspectable
00077 {
00078   NUX_DECLARE_OBJECT_TYPE(AbstractLauncherIcon, ui::IconTextureSource);
00079 public:
00080   typedef nux::ObjectPtr<AbstractLauncherIcon> Ptr;
00081   typedef std::vector<nux::Vector4> TransformVector;
00082 
00083   typedef enum
00084   {
00085     TYPE_NONE,
00086     TYPE_BEGIN,
00087     TYPE_HOME,
00088     TYPE_HUD,
00089     TYPE_FAVORITE,
00090     TYPE_APPLICATION,
00091     TYPE_EXPO,
00092     TYPE_DESKTOP,
00093     TYPE_PLACE,
00094     TYPE_DEVICE,
00095     TYPE_TRASH,
00096     TYPE_END,
00097   } IconType;
00098 
00099   typedef enum
00100   {
00101     QUIRK_VISIBLE,
00102     QUIRK_ACTIVE,
00103     QUIRK_RUNNING,
00104     QUIRK_URGENT,
00105     QUIRK_PRESENTED,
00106     QUIRK_STARTING,
00107     QUIRK_SHIMMER,
00108     QUIRK_CENTER_SAVED,
00109     QUIRK_PROGRESS,
00110     QUIRK_DROP_PRELIGHT,
00111     QUIRK_DROP_DIM,
00112     QUIRK_DESAT,
00113     QUIRK_PULSE_ONCE,
00114     QUIRK_LAST_ACTION,
00115 
00116     QUIRK_LAST,
00117   } Quirk;
00118 
00119   virtual ~AbstractLauncherIcon() {}
00120 
00121   nux::Property<std::string> tooltip_text;
00122   nux::Property<bool> tooltip_enabled;
00123 
00124   virtual void HideTooltip() = 0;
00125 
00126   virtual void    SetShortcut(guint64 shortcut) = 0;
00127 
00128   virtual guint64 GetShortcut() = 0;
00129 
00130   virtual void SetSortPriority(int priority) = 0;
00131 
00132   virtual bool OpenQuicklist(bool select_first_item = false, int monitor = -1) = 0;
00133 
00134   virtual void        SetCenter(nux::Point3 center, int monitor, nux::Geometry parent_geo) = 0;
00135 
00136   virtual nux::Point3 GetCenter(int monitor) = 0;
00137 
00138   virtual nux::Point3 GetSavedCenter(int monitor) = 0;
00139 
00140   virtual void SaveCenter() = 0;
00141 
00142   virtual void Activate(ActionArg arg) = 0;
00143 
00144   virtual void OpenInstance(ActionArg arg) = 0;
00145 
00146   virtual int SortPriority() = 0;
00147 
00148   virtual std::vector<Window> Windows() = 0;
00149 
00150   virtual std::vector<Window> WindowsForMonitor(int monitor) = 0;
00151 
00152   virtual std::vector<Window> WindowsOnViewport() = 0;
00153 
00154   virtual std::string NameForWindow(Window window) = 0;
00155 
00156   virtual const bool WindowVisibleOnMonitor(int monitor) = 0;
00157 
00158   virtual const bool WindowVisibleOnViewport() = 0;
00159 
00160   virtual bool IsSpacer() = 0;
00161 
00162   virtual float PresentUrgency() = 0;
00163 
00164   virtual float GetProgress() = 0;
00165 
00166   virtual bool ShowInSwitcher(bool current) = 0;
00167 
00168   virtual unsigned long long SwitcherPriority() = 0;
00169 
00170   virtual bool GetQuirk(Quirk quirk) const = 0;
00171 
00172   virtual void SetQuirk(Quirk quirk, bool value) = 0;
00173 
00174   virtual struct timespec GetQuirkTime(Quirk quirk) = 0;
00175 
00176   virtual void ResetQuirkTime(Quirk quirk) = 0;
00177 
00178   virtual IconType GetIconType() = 0;
00179 
00180   virtual std::string RemoteUri() = 0;
00181 
00182   virtual std::list<DbusmenuMenuitem*> Menus() = 0;
00183 
00184   virtual nux::DndAction QueryAcceptDrop(DndData const& dnd_data) = 0;
00185 
00186   virtual bool ShouldHighlightOnDrag(DndData const& dnd_data) = 0;
00187 
00188   virtual void AcceptDrop(DndData const& dnd_data) = 0;
00189 
00190   virtual void SendDndEnter() = 0;
00191 
00192   virtual void SendDndLeave() = 0;
00193 
00194   virtual void InsertEntryRemote(LauncherEntryRemote::Ptr const& remote) = 0;
00195   virtual void RemoveEntryRemote(LauncherEntryRemote::Ptr const& remote) = 0;
00196 
00197   virtual std::string DesktopFile() = 0;
00198 
00199   virtual bool IsSticky() const = 0;
00200 
00201   virtual bool IsVisible() const = 0;
00202 
00203   virtual bool IsVisibleOnMonitor(int monitor) const = 0;
00204 
00205   virtual void SetVisibleOnMonitor(int monitor, bool visible) = 0;
00206 
00207   virtual void AboutToRemove() = 0;
00208   
00209   virtual void Stick(bool save = true) = 0;
00210   
00211   virtual void UnStick() = 0;
00212 
00213   sigc::signal<void, int, int, unsigned long> mouse_down;
00214   sigc::signal<void, int, int, unsigned long> mouse_up;
00215   sigc::signal<void, int, int, unsigned long> mouse_click;
00216   sigc::signal<void, int>      mouse_enter;
00217   sigc::signal<void, int>      mouse_leave;
00218 
00219   sigc::signal<void, AbstractLauncherIcon::Ptr> needs_redraw;
00220   sigc::signal<void, AbstractLauncherIcon::Ptr> remove;
00221   sigc::signal<void, nux::ObjectPtr<nux::View>> tooltip_visible;
00222   sigc::signal<void> visibility_changed;
00223 
00224   sigc::connection needs_redraw_connection;
00225   sigc::connection on_icon_added_connection;
00226   sigc::connection on_icon_removed_connection;
00227   sigc::connection on_order_changed_connection;
00228   sigc::connection on_expo_terminated_connection;
00229 };
00230 
00231 }
00232 }
00233 
00234 #endif // LAUNCHERICON_H
00235