1
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
3
* Copyright (C) 2010 Canonical Ltd
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 3 as
7
* published by the Free Software Foundation.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
* Authored by: Jason Smith <jason.smith@canonical.com>
21
#ifndef LAUNCHERICON_H
22
#define LAUNCHERICON_H
28
#include <Nux/BaseWindow.h>
29
#include <NuxCore/Math/MathInc.h>
31
#include <sigc++/trackable.h>
32
#include <sigc++/signal.h>
33
#include <sigc++/functors/ptr_fun.h>
34
#include <sigc++/functors/mem_fun.h>
37
#include <libdbusmenu-glib/client.h>
38
#include <libdbusmenu-glib/menuitem.h>
40
#include <boost/unordered_map.hpp>
42
#include "AbstractLauncherIcon.h"
44
#include "QuicklistView.h"
45
#include "Introspectable.h"
47
#include "LauncherEntryRemote.h"
51
class LauncherIcon : public AbstractLauncherIcon, public unity::Introspectable
53
NUX_DECLARE_OBJECT_TYPE(LauncherIcon, AbstractLauncherIcon);
56
typedef nux::ObjectPtr<nux::BaseTexture> BaseTexturePtr;
58
LauncherIcon(Launcher* launcher);
60
virtual ~LauncherIcon();
62
Launcher* GetLauncher()
67
bool SetTooltipText(std::string& target, std::string const& value);
69
void SetShortcut(guint64 shortcut);
71
guint64 GetShortcut();
73
void SetSortPriority(int priority);
75
void RecvMouseEnter();
77
void RecvMouseLeave();
79
void RecvMouseDown(int button);
81
void RecvMouseUp(int button);
83
void RecvMouseClick(int button);
87
bool OpenQuicklist(bool default_to_first_item = false);
89
void SetCenter(nux::Point3 center);
91
nux::Point3 GetCenter();
93
virtual void Activate(ActionArg arg);
95
void OpenInstance(ActionArg arg);
101
int RelatedWindows();
103
virtual std::vector<Window> RelatedXids () { return std::vector<Window> (); }
105
virtual std::string NameForWindow (Window window) { return std::string(); }
107
bool HasWindowOnViewport();
109
virtual bool IsSpacer()
114
float PresentUrgency();
118
void SetEmblemIconName(const char* name);
120
void SetEmblemText(const char* text);
124
virtual bool ShowInSwitcher()
129
virtual unsigned long long SwitcherPriority()
134
bool GetQuirk(Quirk quirk);
136
void SetQuirk(Quirk quirk, bool value);
138
struct timespec GetQuirkTime(Quirk quirk);
142
virtual nux::Color BackgroundColor();
144
virtual nux::Color GlowColor();
146
const gchar* RemoteUri()
148
return GetRemoteUri();
151
nux::BaseTexture* TextureForSize(int size);
153
nux::BaseTexture* Emblem();
155
std::list<DbusmenuMenuitem*> Menus();
157
void InsertEntryRemote(LauncherEntryRemote* remote);
159
void RemoveEntryRemote(LauncherEntryRemote* remote);
161
nux::DndAction QueryAcceptDrop(unity::DndData& dnd_data)
163
return OnQueryAcceptDrop(dnd_data);
166
void AcceptDrop(unity::DndData& dnd_data)
168
return OnAcceptDrop(dnd_data);
181
void SetIconType(IconType type);
183
std::vector<nux::Vector4> & GetTransform(TransformIndex index);
185
static void SetSkipTooltipDelay(gboolean skip_tooltip_delay);
187
sigc::signal<void, LauncherIcon*> remove;
189
sigc::connection needs_redraw_connection;
190
sigc::connection on_icon_added_connection;
191
sigc::connection on_icon_removed_connection;
192
sigc::connection on_order_changed_connection;
195
const gchar* GetName();
197
void AddProperties(GVariantBuilder* builder);
199
void UpdateQuirkTimeDelayed(guint ms, Quirk quirk);
201
void UpdateQuirkTime(Quirk quirk);
203
void ResetQuirkTime(Quirk quirk);
205
void SetRelatedWindows(int windows);
209
void SetProgress(float progress);
211
void SetHasWindowOnViewport(bool val);
213
void Present(float urgency, int length);
217
void SetEmblem(BaseTexturePtr const& emblem);
219
virtual std::list<DbusmenuMenuitem*> GetMenus();
221
virtual nux::BaseTexture* GetTextureForSize(int size) = 0;
223
virtual void OnCenterStabilized(nux::Point3 center) {}
225
virtual const gchar* GetRemoteUri()
230
virtual nux::DndAction OnQueryAcceptDrop(unity::DndData& dnd_data)
232
return nux::DNDACTION_NONE;
235
virtual void OnAcceptDrop(unity::DndData& dnd_data) {}
237
virtual void OnDndEnter() {}
239
virtual void OnDndLeave() {}
241
virtual void ActivateLauncherIcon(ActionArg arg) {}
243
virtual void OpenInstanceLauncherIcon(ActionArg arg) {}
245
virtual bool HandlesSpread () { return false; }
247
nux::BaseTexture* TextureFromGtkTheme(const char* name, int size, bool update_glow_colors = true);
249
nux::BaseTexture* TextureFromSpecificGtkTheme(GtkIconTheme* theme, const char* name, int size, bool update_glow_colors = true, bool is_default_theme = false);
251
nux::BaseTexture* TextureFromPath(const char* name, int size, bool update_glow_colors = true);
253
static bool IsMonoDefaultTheme();
255
GtkIconTheme* GetUnityTheme();
257
void OnRemoteEmblemChanged(LauncherEntryRemote* remote);
259
void OnRemoteCountChanged(LauncherEntryRemote* remote);
261
void OnRemoteProgressChanged(LauncherEntryRemote* remote);
263
void OnRemoteQuicklistChanged(LauncherEntryRemote* remote);
265
void OnRemoteUrgentChanged(LauncherEntryRemote* remote);
267
void OnRemoteEmblemVisibleChanged(LauncherEntryRemote* remote);
269
void OnRemoteCountVisibleChanged(LauncherEntryRemote* remote);
271
void OnRemoteProgressVisibleChanged(LauncherEntryRemote* remote);
275
nux::Tooltip* _tooltip;
276
QuicklistView* _quicklist;
278
static nux::Tooltip* _current_tooltip;
279
static QuicklistView* _current_quicklist;
281
// This looks like a case for boost::logical::tribool
282
static int _current_theme_is_mono;
284
DbusmenuClient* _menuclient_dynamic_quicklist;
286
friend class Launcher;
287
friend class LauncherController;
288
friend class LauncherModel;
297
static void ChildRealized(DbusmenuMenuitem* newitem, QuicklistView* quicklist);
298
static void RootChanged(DbusmenuClient* client, DbusmenuMenuitem* newroot, QuicklistView* quicklist);
299
static gboolean OnPresentTimeout(gpointer data);
300
static gboolean OnCenterTimeout(gpointer data);
301
static gboolean OnDelayedUpdateTimeout(gpointer data);
302
static gboolean OnTooltipTimeout(gpointer data);
304
void ColorForIcon(GdkPixbuf* pixbuf, nux::Color& background, nux::Color& glow);
305
void SetTooltipAnchorTip();
306
void SetQuicklistAnchorTip();
308
bool _has_visible_window;
309
bool _quicklist_is_initialized;
311
float _present_urgency;
313
guint _center_stabilize_handle;
314
guint _present_time_handle;
315
guint _time_delay_handle;
316
guint _tooltip_delay_handle;
317
int _related_windows;
319
nux::Color _background_color;
320
nux::Color _glow_color;
321
static gboolean _skip_tooltip_delay;
326
nux::Point3 _last_stable;
327
nux::Point3 _saved_center;
330
static GtkIconTheme* _unity_theme;
332
BaseTexturePtr _emblem;
334
bool _quirks[QUIRK_LAST];
335
struct timespec _quirk_times[QUIRK_LAST];
337
std::list<LauncherEntryRemote*> _entry_list;
338
std::map<TransformIndex, std::vector<nux::Vector4> > transform_map;
342
#endif // LAUNCHERICON_H