summaryrefslogtreecommitdiff
diff options
authorJason Smith <jason.smith@canonical.com>2012-02-09 02:12:15 -0500
committerTarmac <>2012-02-09 02:12:15 -0500
commit4af298c615e15d945e9e89c3a8c6c503db9e40ec (patch)
tree212bcab282ac1755d04fcce75b561c03ecc50872
parentbe016f6f6155c603f200a7aa2acfd4251166ecb9 (diff)
parent553beefc40ba0c09d7293998c849c9e5492c2be9 (diff)
. Fixes: . Approved by Thomi Richards.
(bzr r1938)
-rw-r--r--plugins/unityshell/src/Launcher.cpp14
-rw-r--r--plugins/unityshell/src/LauncherIcon.cpp58
-rw-r--r--plugins/unityshell/src/LauncherIcon.h9
3 files changed, 43 insertions, 38 deletions
diff --git a/plugins/unityshell/src/Launcher.cpp b/plugins/unityshell/src/Launcher.cpp
index b1bc213b8..1686b8144 100644
--- a/plugins/unityshell/src/Launcher.cpp
+++ b/plugins/unityshell/src/Launcher.cpp
@@ -285,18 +285,8 @@ Launcher::Launcher(nux::BaseWindow* parent,
bg_effect_helper_.enabled = false;
TextureCache& cache = TextureCache::GetDefault();
- TextureCache::CreateTextureCallback cb = [&](std::string const& name, int width, int height) -> nux::BaseTexture*
- {
- unity::glib::Object<GdkPixbuf> pixbuf;
- unity::glib::Error error;
-
- pixbuf = gdk_pixbuf_new_from_file((PKGDATADIR"/" + name + ".png").c_str(), &error);
- if (error)
- LOG_WARN(logger) << "Unable to load texture " << PKGDATADIR"/" << name << ": " << error;
- else
- return nux::CreateTexture2DFromPixbuf(pixbuf, true);
-
- return nullptr;
+ TextureCache::CreateTextureCallback cb = [&](std::string const& name, int width, int height) -> nux::BaseTexture* {
+ return nux::CreateTexture2DFromFile((PKGDATADIR"/" + name + ".png").c_str(), -1, true);
};
launcher_sheen_ = cache.FindTexture("dash_sheen", 0, 0, cb);
diff --git a/plugins/unityshell/src/LauncherIcon.cpp b/plugins/unityshell/src/LauncherIcon.cpp
index 119342ad1..d68410604 100644
--- a/plugins/unityshell/src/LauncherIcon.cpp
+++ b/plugins/unityshell/src/LauncherIcon.cpp
@@ -70,7 +70,6 @@ GtkIconTheme* LauncherIcon::_unity_theme = NULL;
LauncherIcon::LauncherIcon()
: _menuclient_dynamic_quicklist(nullptr)
- , _quicklist_is_initialized(false)
, _remote_urgent(false)
, _present_urgency(0)
, _progress(0)
@@ -96,20 +95,12 @@ LauncherIcon::LauncherIcon()
_quirk_times[i].tv_nsec = 0;
}
- _tooltip = new Tooltip();
-
tooltip_text.SetSetterFunction(sigc::mem_fun(this, &LauncherIcon::SetTooltipText));
tooltip_text = "blank";
- _quicklist = new QuicklistView();
-
// FIXME: the abstraction is already broken, should be fixed for O
// right now, hooking the dynamic quicklist the less ugly possible way
- QuicklistManager::Default()->RegisterQuicklist(_quicklist.GetPointer());
-
- // Add to introspection
- AddChild(_quicklist.GetPointer());
- AddChild(_tooltip.GetPointer());
+
mouse_enter.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseEnter));
mouse_leave.connect(sigc::mem_fun(this, &LauncherIcon::RecvMouseLeave));
@@ -122,10 +113,6 @@ LauncherIcon::~LauncherIcon()
{
SetQuirk(QUIRK_URGENT, false);
- // Remove from introspection
- RemoveChild(_quicklist.GetPointer());
- RemoveChild(_tooltip.GetPointer());
-
if (_present_time_handle)
g_source_remove(_present_time_handle);
_present_time_handle = 0;
@@ -158,6 +145,22 @@ LauncherIcon::~LauncherIcon()
}
}
+void LauncherIcon::LoadTooltip()
+{
+ _tooltip = new Tooltip();
+ AddChild(_tooltip.GetPointer());
+
+ _tooltip->SetText(nux::NString(tooltip_text().c_str()));
+}
+
+void LauncherIcon::LoadQuicklist()
+{
+ _quicklist = new QuicklistView();
+ AddChild(_quicklist.GetPointer());
+
+ QuicklistManager::Default()->RegisterQuicklist(_quicklist.GetPointer());
+}
+
const bool
LauncherIcon::WindowVisibleOnMonitor(int monitor)
{
@@ -451,7 +454,8 @@ bool LauncherIcon::SetTooltipText(std::string& target, std::string const& value)
if (escaped != target)
{
target = escaped;
- _tooltip->SetText(nux::NString(target.c_str()));
+ if (_tooltip)
+ _tooltip->SetText(nux::NString(target.c_str()));
result = true;
}
@@ -476,7 +480,7 @@ LauncherIcon::GetShortcut()
void
LauncherIcon::ShowTooltip()
{
- if (_quicklist->IsVisible())
+ if (_quicklist && _quicklist->IsVisible())
return;
int tip_x = 100;
@@ -488,6 +492,8 @@ LauncherIcon::ShowTooltip()
tip_y = geo.y + _center[_last_monitor].y;
}
+ if (!_tooltip)
+ LoadTooltip();
_tooltip->ShowTooltipWithTipAt(tip_x, tip_y);
_tooltip->ShowWindow(!tooltip_text().empty());
}
@@ -509,17 +515,22 @@ void LauncherIcon::RecvMouseLeave(int monitor)
{
_last_monitor = -1;
- _tooltip->ShowWindow(false);
+ if (_tooltip)
+ _tooltip->ShowWindow(false);
}
bool LauncherIcon::OpenQuicklist(bool default_to_first_item, int monitor)
{
std::list<DbusmenuMenuitem*> menus = Menus();
+ if (!_quicklist)
+ LoadQuicklist();
+
if (menus.empty())
return false;
- _tooltip->ShowWindow(false);
+ if (_tooltip)
+ _tooltip->ShowWindow(false);
_quicklist->RemoveAllMenuItem();
for (auto menu_item : menus)
@@ -601,7 +612,7 @@ void LauncherIcon::RecvMouseUp(int button, int monitor)
{
if (button == 3)
{
- if (_quicklist->IsVisible())
+ if (_quicklist && _quicklist->IsVisible())
_quicklist->CaptureMouseDownAnyWhereElse(true);
}
}
@@ -619,7 +630,8 @@ void LauncherIcon::RecvMouseClick(int button, int monitor)
void LauncherIcon::HideTooltip()
{
- _tooltip->ShowWindow(false);
+ if (_tooltip)
+ _tooltip->ShowWindow(false);
}
gboolean
@@ -649,9 +661,9 @@ LauncherIcon::SetCenter(nux::Point3 center, int monitor, nux::Geometry geo)
tip_x = geo.x + geo.width - 4 * geo.width / 48;
tip_y = geo.y + _center[monitor].y;
- if (_quicklist->IsVisible())
+ if (_quicklist && _quicklist->IsVisible())
QuicklistManager::Default()->ShowQuicklist(_quicklist.GetPointer(), tip_x, tip_y);
- else if (_tooltip->IsVisible())
+ else if (_tooltip && _tooltip->IsVisible())
_tooltip->ShowTooltipWithTipAt(tip_x, tip_y);
}
@@ -742,7 +754,7 @@ LauncherIcon::Unpresent()
void
LauncherIcon::Remove()
{
- if (_quicklist->IsVisible())
+ if (_quicklist && _quicklist->IsVisible())
_quicklist->Hide();
SetQuirk(QUIRK_VISIBLE, false);
diff --git a/plugins/unityshell/src/LauncherIcon.h b/plugins/unityshell/src/LauncherIcon.h
index 0155f2325..6d45c8d39 100644
--- a/plugins/unityshell/src/LauncherIcon.h
+++ b/plugins/unityshell/src/LauncherIcon.h
@@ -263,8 +263,6 @@ protected:
void OnRemoteProgressVisibleChanged(LauncherEntryRemote* remote);
- nux::ObjectPtr<Tooltip> _tooltip;
- nux::ObjectPtr<QuicklistView> _quicklist;
// This looks like a case for boost::logical::tribool
static int _current_theme_is_mono;
@@ -278,6 +276,9 @@ private:
Quirk quirk;
} DelayedUpdateArg;
+ nux::ObjectPtr<Tooltip> _tooltip;
+ nux::ObjectPtr<QuicklistView> _quicklist;
+
static void ChildRealized(DbusmenuMenuitem* newitem, QuicklistView* quicklist);
static void RootChanged(DbusmenuClient* client, DbusmenuMenuitem* newroot, QuicklistView* quicklist);
static gboolean OnPresentTimeout(gpointer data);
@@ -286,8 +287,10 @@ private:
void ColorForIcon(GdkPixbuf* pixbuf, nux::Color& background, nux::Color& glow);
+ void LoadTooltip();
+ void LoadQuicklist();
+
std::vector<bool> _has_visible_window;
- bool _quicklist_is_initialized;
bool _remote_urgent;
float _present_urgency;
float _progress;