~smspillaz/unity/untiy.less-paint-insanity

« back to all changes in this revision

Viewing changes to plugins/unityshell/src/IconTexture.cpp

  • Committer: Daniel van Vugt
  • Date: 2012-03-14 06:24:18 UTC
  • mfrom: (2108 unity)
  • mto: This revision was merged to the branch mainline in revision 2146.
  • Revision ID: daniel.van.vugt@canonical.com-20120314062418-nprucpbr0m7qky5e
MergedĀ latestĀ lp:unity

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include <pango/pangocairo.h>
25
25
 
26
26
#include <Nux/Nux.h>
 
27
#include <NuxCore/Logger.h>
27
28
#include <NuxGraphics/GLThread.h>
28
29
#include <UnityCore/GLibWrapper.h>
29
30
#include <UnityCore/Variant.h>
37
38
namespace
38
39
{
39
40
const char* const DEFAULT_ICON = "text-x-preview";
 
41
nux::logging::Logger logger("unity.icontexture");
40
42
}
41
43
 
42
44
using namespace unity;
43
45
 
44
46
IconTexture::IconTexture(nux::BaseTexture* texture, guint width, guint height)
45
47
  : TextureArea(NUX_TRACKER_LOCATION),
 
48
    _accept_key_nav_focus(false),
46
49
    _icon_name(NULL),
47
50
    _size(height),
48
51
    _texture_cached(texture),
52
55
    _opacity(1.0f)
53
56
{
54
57
  SetMinMaxSize(width, height);
55
 
 
56
 
  _accept_key_nav_focus = false;
57
58
}
58
59
 
59
60
IconTexture::IconTexture(const char* icon_name, unsigned int size, bool defer_icon_loading)
60
61
  : TextureArea(NUX_TRACKER_LOCATION),
 
62
    _accept_key_nav_focus(false),
61
63
    _icon_name(NULL),
62
64
    _size(size),
63
65
    _texture_width(0),
67
69
{
68
70
  _icon_name = g_strdup(icon_name ? icon_name : DEFAULT_ICON);
69
71
 
70
 
  if (!g_strcmp0(_icon_name, "") == 0 && !defer_icon_loading)
 
72
  if (g_strcmp0(_icon_name, "") != 0 && !defer_icon_loading)
71
73
    LoadIcon();
72
74
}
73
75
 
95
97
 
96
98
void IconTexture::LoadIcon()
97
99
{
98
 
  static const char* const DEFAULT_GICON = ". GThemedIcon text-x-preview";
99
 
 
 
100
  LOG_DEBUG(logger) << "LoadIcon called (" << _icon_name << ") - loading: " << _loading;
 
101
static const char* const DEFAULT_GICON = ". GThemedIcon text-x-preview";
 
102
  if (!g_strcmp0(_icon_name, ""))
 
103
    return;
 
104
 
100
105
  if (_loading)
101
106
    return;
102
107
  _loading = true;
144
149
                                      _texture_height,
145
150
                                      sigc::mem_fun(this, &IconTexture::CreateTextureCallback));
146
151
  QueueDraw();
 
152
  _loading = false;
147
153
}
148
154
 
149
155
void IconTexture::IconLoaded(std::string const& icon_name, unsigned size,
162
168
    if (icon_name != DEFAULT_ICON)
163
169
      SetByIconName(DEFAULT_ICON, _size);
164
170
  }
 
171
 
 
172
  texture_updated.emit(_texture_cached.GetPointer());
 
173
  QueueDraw();
165
174
}
166
175
 
167
176
void IconTexture::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)