~jamespharaoh/ubuntu/oneiric/unity/fix-for-880672

« back to all changes in this revision

Viewing changes to .pc/debian-changes-4.8.2-0ubuntu3/plugins/unityshell/src/MockLauncherIcon.h

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2011-08-19 18:53:28 UTC
  • Revision ID: james.westby@ubuntu.com-20110819185328-qaxk9eepjaghewu9
Tags: 4.8.2-0ubuntu4
Backport another trunk commit to fix an alt-tab segfault

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2
 
/*
3
 
 * Copyright (C) 2010 Canonical Ltd
4
 
 *
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.
8
 
 *
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.
13
 
 *
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/>.
16
 
 *
17
 
 * Authored by: Jason Smith <jason.smith@canonical.com>
18
 
 *
19
 
 */
20
 
 
21
 
#ifndef MOCKLAUNCHERICON_H
22
 
#define MOCKLAUNCHERICON_H
23
 
 
24
 
#include <Nux/Nux.h>
25
 
#include <NuxCore/Math/MathInc.h>
26
 
 
27
 
#include <Nux/BaseWindow.h>
28
 
#include <Nux/View.h>
29
 
 
30
 
#include <sigc++/sigc++.h>
31
 
 
32
 
#include <libdbusmenu-glib/menuitem.h>
33
 
 
34
 
#include "AbstractLauncherIcon.h"
35
 
 
36
 
class MockLauncherIcon : public AbstractLauncherIcon
37
 
{
38
 
public:
39
 
  MockLauncherIcon()
40
 
    : icon_(0)
41
 
  {
42
 
    tooltip_text = "Mock Icon";
43
 
  }
44
 
 
45
 
  void HideTooltip() {}
46
 
 
47
 
  void    SetShortcut(guint64 shortcut) {}
48
 
 
49
 
  guint64 GetShortcut()
50
 
  {
51
 
    return 0;
52
 
  }
53
 
 
54
 
  std::vector<Window> RelatedXids ()
55
 
  {
56
 
    std::vector<Window> result;
57
 
    return result;
58
 
  }
59
 
 
60
 
  void SetSortPriority(int priority) {}
61
 
 
62
 
  bool OpenQuicklist(bool default_to_first_item = false)
63
 
  {
64
 
    return false;
65
 
  }
66
 
 
67
 
  void        SetCenter(nux::Point3 center) {}
68
 
 
69
 
  nux::Point3 GetCenter()
70
 
  {
71
 
    return nux::Point3();
72
 
  }
73
 
 
74
 
  std::vector<nux::Vector4> & GetTransform(std::string const& name)
75
 
  {
76
 
    if (transform_map.find(name) == transform_map.end())
77
 
      transform_map[name] = std::vector<nux::Vector4> (4);
78
 
 
79
 
    return transform_map[name];
80
 
  }
81
 
 
82
 
  void Activate(ActionArg arg) {}
83
 
 
84
 
  void OpenInstance(ActionArg arg) {}
85
 
 
86
 
  int SortPriority()
87
 
  {
88
 
    return 0;
89
 
  }
90
 
 
91
 
  int RelatedWindows()
92
 
  {
93
 
    return 0;
94
 
  }
95
 
 
96
 
  bool HasWindowOnViewport()
97
 
  {
98
 
    return false;
99
 
  }
100
 
 
101
 
  bool IsSpacer()
102
 
  {
103
 
    return false;
104
 
  }
105
 
 
106
 
  float PresentUrgency()
107
 
  {
108
 
    return 0.0f;
109
 
  }
110
 
 
111
 
  float GetProgress()
112
 
  {
113
 
    return 0.0f;
114
 
  }
115
 
 
116
 
  bool ShowInSwitcher()
117
 
  {
118
 
    return true;
119
 
  }
120
 
 
121
 
  unsigned int SwitcherPriority()
122
 
  {
123
 
    return 0;
124
 
  }
125
 
 
126
 
  bool GetQuirk(Quirk quirk)
127
 
  {
128
 
    return false;
129
 
  }
130
 
 
131
 
  void SetQuirk(Quirk quirk, bool value) {}
132
 
 
133
 
  struct timespec GetQuirkTime(Quirk quirk)
134
 
  {
135
 
    timespec tv;
136
 
    return tv;
137
 
  }
138
 
 
139
 
  IconType Type()
140
 
  {
141
 
    return TYPE_APPLICATION;
142
 
  }
143
 
 
144
 
  nux::Color BackgroundColor()
145
 
  {
146
 
    return nux::Color(0xFFAAAAAA);
147
 
  }
148
 
 
149
 
  nux::Color GlowColor()
150
 
  {
151
 
    return nux::Color(0xFFAAAAAA);
152
 
  }
153
 
 
154
 
  const gchar* RemoteUri()
155
 
  {
156
 
    return "fake";
157
 
  }
158
 
 
159
 
  nux::BaseTexture* TextureForSize(int size)
160
 
  {
161
 
    if (icon_ && size == icon_->GetHeight())
162
 
      return icon_;
163
 
 
164
 
    if (icon_)
165
 
      icon_->UnReference();
166
 
    icon_ = 0;
167
 
 
168
 
    icon_ = TextureFromGtkTheme("firefox", size);
169
 
    return icon_;
170
 
  }
171
 
 
172
 
  nux::BaseTexture* Emblem()
173
 
  {
174
 
    return 0;
175
 
  }
176
 
 
177
 
  std::list<DbusmenuMenuitem*> Menus()
178
 
  {
179
 
    return std::list<DbusmenuMenuitem*> ();
180
 
  }
181
 
 
182
 
  nux::DndAction QueryAcceptDrop(std::list<char*> paths)
183
 
  {
184
 
    return nux::DNDACTION_NONE;
185
 
  }
186
 
 
187
 
  void AcceptDrop(std::list<char*> paths) {}
188
 
 
189
 
  void SendDndEnter() {}
190
 
 
191
 
  void SendDndLeave() {}
192
 
 
193
 
private:
194
 
  nux::BaseTexture* TextureFromGtkTheme(const char* icon_name, int size)
195
 
  {
196
 
    GdkPixbuf* pbuf;
197
 
    GtkIconInfo* info;
198
 
    nux::BaseTexture* result = NULL;
199
 
    GError* error = NULL;
200
 
    GIcon* icon;
201
 
 
202
 
    GtkIconTheme* theme = gtk_icon_theme_get_default();
203
 
 
204
 
    icon = g_icon_new_for_string(icon_name, NULL);
205
 
 
206
 
    if (G_IS_ICON(icon))
207
 
    {
208
 
      info = gtk_icon_theme_lookup_by_gicon(theme, icon, size, (GtkIconLookupFlags)0);
209
 
      g_object_unref(icon);
210
 
    }
211
 
    else
212
 
    {
213
 
      info = gtk_icon_theme_lookup_icon(theme,
214
 
                                        icon_name,
215
 
                                        size,
216
 
                                        (GtkIconLookupFlags) 0);
217
 
    }
218
 
 
219
 
    if (!info)
220
 
      return NULL;
221
 
 
222
 
    pbuf = gtk_icon_info_load_icon(info, &error);
223
 
    gtk_icon_info_free(info);
224
 
 
225
 
    if (GDK_IS_PIXBUF(pbuf))
226
 
    {
227
 
      result = nux::CreateTexture2DFromPixbuf(pbuf, true);
228
 
      g_object_unref(pbuf);
229
 
    }
230
 
    else
231
 
    {
232
 
      g_warning("Unable to load '%s' from icon theme: %s",
233
 
                icon_name,
234
 
                error ? error->message : "unknown");
235
 
      g_error_free(error);
236
 
    }
237
 
 
238
 
    return result;
239
 
  }
240
 
 
241
 
 
242
 
  std::map<std::string, std::vector<nux::Vector4> > transform_map;
243
 
  nux::BaseTexture* icon_;
244
 
 
245
 
};
246
 
 
247
 
#endif // MOCKLAUNCHERICON_H
248