~ken-vandine/unity/make-quicklists-work-again

« back to all changes in this revision

Viewing changes to src/LauncherIcon.h

  • Committer: Neil Jagdish Patel
  • Date: 2010-11-11 18:51:08 UTC
  • mfrom: (572.1.58 unity-3.0)
  • Revision ID: neil.patel@canonical.com-20101111185108-71923a90txzvxbit
[merge] Unity 3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2010 Canonical Ltd
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License version 3 as
 
6
 * published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by: Jason Smith <jason.smith@canonical.com>
 
17
 * 
 
18
 */
 
19
 
 
20
#ifndef LAUNCHERICON_H
 
21
#define LAUNCHERICON_H
 
22
 
 
23
#include <Nux/Nux.h>
 
24
#include <Nux/BaseWindow.h>
 
25
#include <NuxCore/Math/MathInc.h>
 
26
 
 
27
#include <sigc++/trackable.h>
 
28
#include <sigc++/signal.h>
 
29
#include <sigc++/functors/ptr_fun.h>
 
30
#include <sigc++/functors/mem_fun.h>
 
31
 
 
32
#include <gtk/gtk.h>
 
33
#include <libdbusmenu-glib/client.h>
 
34
 
 
35
#include "Tooltip.h"
 
36
 
 
37
class Launcher;
 
38
 
 
39
typedef enum
 
40
{
 
41
  LAUNCHER_ICON_TYPE_NONE,
 
42
  LAUNCHER_ICON_TYPE_BEGIN,
 
43
  LAUNCHER_ICON_TYPE_FAVORITE,
 
44
  LAUNCHER_ICON_TYPE_APPLICATION,
 
45
  LAUNCHER_ICON_TYPE_PLACE,
 
46
  LAUNCHER_ICON_TYPE_DEVICE,
 
47
  LAUNCHER_ICON_TYPE_TRASH,
 
48
  LAUNCHER_ICON_TYPE_END,
 
49
} LauncherIconType;
 
50
 
 
51
class LauncherIcon: public nux::InitiallyUnownedObject, public sigc::trackable
 
52
{
 
53
public:
 
54
    LauncherIcon(Launcher* IconManager);
 
55
    ~LauncherIcon();
 
56
 
 
57
    void         SetTooltipText (const TCHAR* text);
 
58
    
 
59
    nux::NString GetTooltipText ();
 
60
    
 
61
    bool Visible ();
 
62
    bool Active  ();
 
63
    bool Running ();
 
64
    bool Urgent  ();
 
65
 
 
66
    void RecvMouseEnter ();
 
67
    void RecvMouseLeave ();
 
68
    
 
69
    void HideTooltip ();
 
70
    
 
71
    int SortPriority ();
 
72
    
 
73
    int RelatedWindows ();
 
74
    
 
75
    struct timeval ShowTime ();
 
76
    struct timeval HideTime ();
 
77
    struct timeval RunningTime ();
 
78
    struct timeval UrgentTime ();
 
79
    
 
80
    LauncherIconType Type ();
 
81
    
 
82
    nux::Color BackgroundColor ();
 
83
    
 
84
    nux::BaseTexture * TextureForSize (int size);
 
85
    
 
86
    std::list<DbusmenuClient *> Menus ();
 
87
    
 
88
    sigc::signal<void, int> MouseDown;
 
89
    sigc::signal<void, int> MouseUp;
 
90
    sigc::signal<void> MouseEnter;
 
91
    sigc::signal<void> MouseLeave;
 
92
    sigc::signal<void, int> MouseClick;
 
93
    
 
94
    sigc::signal<void, void *> show;
 
95
    sigc::signal<void, void *> hide;
 
96
    sigc::signal<void, void *> remove;
 
97
    sigc::signal<void, void *> needs_redraw;
 
98
protected:
 
99
 
 
100
    void SetVisible (bool visible);
 
101
    void SetActive  (bool active);
 
102
    void SetRunning (bool running);
 
103
    void SetUrgent  (bool urgent);
 
104
    void SetRelatedWindows (int windows);
 
105
    void Remove ();
 
106
    
 
107
    void SetIconType (LauncherIconType type);
 
108
    void SetSortPriority (int priority);
 
109
 
 
110
    virtual std::list<DbusmenuClient *> GetMenus ();
 
111
    virtual nux::BaseTexture * GetTextureForSize (int size) = 0;
 
112
 
 
113
    nux::BaseTexture * TextureFromGtkTheme (const char *name, int size);
 
114
 
 
115
    nux::NString m_TooltipText;
 
116
    //! the window this icon belong too.
 
117
    nux::BaseWindow* m_Window;
 
118
    Launcher* m_IconManager;
 
119
 
 
120
    nux::Vector4  _xform_screen_coord [4];
 
121
    nux::Vector4  _xform_icon_screen_coord [4];
 
122
    bool          _mouse_inside;
 
123
    float         _folding_angle;
 
124
 
 
125
    nux::Tooltip* _tooltip;
 
126
 
 
127
 
 
128
    friend class Launcher;
 
129
    friend class LauncherController;
 
130
 
 
131
private:
 
132
    nux::Color ColorForIcon (GdkPixbuf *pixbuf);
 
133
 
 
134
    nux::Color       _background_color;
 
135
    bool             _visible;
 
136
    bool             _active;
 
137
    bool             _running;
 
138
    bool             _urgent;
 
139
    int              _sort_priority;
 
140
    int              _related_windows;
 
141
    LauncherIconType _icon_type;
 
142
    struct timeval   _show_time;
 
143
    struct timeval   _hide_time;
 
144
    struct timeval   _running_time;
 
145
    struct timeval   _urgent_time;
 
146
};
 
147
 
 
148
#endif // LAUNCHERICON_H
 
149