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 MOCKLAUNCHERICON_H
22
#define MOCKLAUNCHERICON_H
25
#include <NuxCore/Math/MathInc.h>
27
#include <Nux/BaseWindow.h>
30
#include <sigc++/sigc++.h>
32
#include <libdbusmenu-glib/menuitem.h>
34
#include "AbstractLauncherIcon.h"
36
class MockLauncherIcon : public AbstractLauncherIcon
42
tooltip_text = "Mock Icon";
47
void SetShortcut(guint64 shortcut) {}
54
std::vector<Window> RelatedXids ()
56
std::vector<Window> result;
60
void SetSortPriority(int priority) {}
62
bool OpenQuicklist(bool default_to_first_item = false)
67
void SetCenter(nux::Point3 center) {}
69
nux::Point3 GetCenter()
74
std::vector<nux::Vector4> & GetTransform(std::string const& name)
76
if (transform_map.find(name) == transform_map.end())
77
transform_map[name] = std::vector<nux::Vector4> (4);
79
return transform_map[name];
82
void Activate(ActionArg arg) {}
84
void OpenInstance(ActionArg arg) {}
96
bool HasWindowOnViewport()
106
float PresentUrgency()
116
bool ShowInSwitcher()
121
unsigned int SwitcherPriority()
126
bool GetQuirk(Quirk quirk)
131
void SetQuirk(Quirk quirk, bool value) {}
133
struct timespec GetQuirkTime(Quirk quirk)
141
return TYPE_APPLICATION;
144
nux::Color BackgroundColor()
146
return nux::Color(0xFFAAAAAA);
149
nux::Color GlowColor()
151
return nux::Color(0xFFAAAAAA);
154
const gchar* RemoteUri()
159
nux::BaseTexture* TextureForSize(int size)
161
if (icon_ && size == icon_->GetHeight())
165
icon_->UnReference();
168
icon_ = TextureFromGtkTheme("firefox", size);
172
nux::BaseTexture* Emblem()
177
std::list<DbusmenuMenuitem*> Menus()
179
return std::list<DbusmenuMenuitem*> ();
182
nux::DndAction QueryAcceptDrop(std::list<char*> paths)
184
return nux::DNDACTION_NONE;
187
void AcceptDrop(std::list<char*> paths) {}
189
void SendDndEnter() {}
191
void SendDndLeave() {}
194
nux::BaseTexture* TextureFromGtkTheme(const char* icon_name, int size)
198
nux::BaseTexture* result = NULL;
199
GError* error = NULL;
202
GtkIconTheme* theme = gtk_icon_theme_get_default();
204
icon = g_icon_new_for_string(icon_name, NULL);
208
info = gtk_icon_theme_lookup_by_gicon(theme, icon, size, (GtkIconLookupFlags)0);
209
g_object_unref(icon);
213
info = gtk_icon_theme_lookup_icon(theme,
216
(GtkIconLookupFlags) 0);
222
pbuf = gtk_icon_info_load_icon(info, &error);
223
gtk_icon_info_free(info);
225
if (GDK_IS_PIXBUF(pbuf))
227
result = nux::CreateTexture2DFromPixbuf(pbuf, true);
228
g_object_unref(pbuf);
232
g_warning("Unable to load '%s' from icon theme: %s",
234
error ? error->message : "unknown");
242
std::map<std::string, std::vector<nux::Vector4> > transform_map;
243
nux::BaseTexture* icon_;
247
#endif // MOCKLAUNCHERICON_H