diff options
| author | Gord Allott <gord.allott@canonical.com> | 2012-08-10 16:13:35 +0100 |
|---|---|---|
| committer | Gord Allott <gord.allott@canonical.com> | 2012-08-10 16:13:35 +0100 |
| commit | 19a9ad3b86b55fbe09dd8003a21ee61c260c5c20 (patch) | |
| tree | e73bebe4dba1cbae73eddc9a153040365e296678 /dash | |
| parent | c3f1515c91ccbd3b1d6e6ea8cc9f695e8320beac (diff) | |
| parent | 4af96d27e4489a8c61dbf26db116cca66b3a8f0d (diff) | |
latest preview ui code
(bzr r2419.6.21)
Diffstat (limited to 'dash')
| -rw-r--r-- | dash/previews/ActionButton.cpp | 5 | ||||
| -rw-r--r-- | dash/previews/ActionButton.h | 2 | ||||
| -rw-r--r-- | dash/previews/MoviePreview.cpp | 2 | ||||
| -rw-r--r-- | dash/previews/PreviewContainer.cpp | 171 | ||||
| -rw-r--r-- | dash/previews/PreviewContainer.h | 2 | ||||
| -rw-r--r-- | dash/previews/PreviewInfoHintWidget.cpp | 79 | ||||
| -rw-r--r-- | dash/previews/PreviewInfoHintWidget.h | 7 | ||||
| -rw-r--r-- | dash/previews/StandaloneApplicationPreview.cpp | 65 |
8 files changed, 225 insertions, 108 deletions
diff --git a/dash/previews/ActionButton.cpp b/dash/previews/ActionButton.cpp index b65e4f438..9f49b3a6c 100644 --- a/dash/previews/ActionButton.cpp +++ b/dash/previews/ActionButton.cpp @@ -94,14 +94,13 @@ void ActionButton::BuildLayout(std::string const& label, std::string const& icon icon_hint_ = icon_hint; if (image_) { - image_->UnReference(); + image_.Release(); image_ = NULL; } if (!icon_hint_.empty()) { image_ = new IconTexture(icon_hint, icon_size); - image_->Reference(); image_->texture_updated.connect([&](nux::BaseTexture*) { BuildLayout(label_, icon_hint_); @@ -137,7 +136,7 @@ void ActionButton::BuildLayout(std::string const& label, std::string const& icon layout->SetPadding(2, 11, 2, 11); layout->AddSpace(0,1); if (image_) - layout->AddView(image_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT); + layout->AddView(image_.GetPointer(), 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT); if (static_text_) layout->AddView(static_text_.GetPointer(), 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT); layout->AddSpace(0,1); diff --git a/dash/previews/ActionButton.h b/dash/previews/ActionButton.h index 7c3e3cb32..d2bb11ef5 100644 --- a/dash/previews/ActionButton.h +++ b/dash/previews/ActionButton.h @@ -79,7 +79,7 @@ private: std::string icon_hint_; std::string font_hint_; - IconTexture* image_; + nux::ObjectPtr<IconTexture> image_; nux::ObjectPtr<nux::StaticCairoText> static_text_; }; diff --git a/dash/previews/MoviePreview.cpp b/dash/previews/MoviePreview.cpp index 7154284d0..290d90d88 100644 --- a/dash/previews/MoviePreview.cpp +++ b/dash/previews/MoviePreview.cpp @@ -218,7 +218,7 @@ void MoviePreview::SetupView() if (!preview_model_->GetInfoHints().empty()) { - PreviewInfoHintWidget* preview_info_hints = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth(), false, true); + PreviewInfoHintWidget* preview_info_hints = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth()); preview_info_layout->AddView(preview_info_hints, 0); } diff --git a/dash/previews/PreviewContainer.cpp b/dash/previews/PreviewContainer.cpp index c37b1ee42..a2bcdd29d 100644 --- a/dash/previews/PreviewContainer.cpp +++ b/dash/previews/PreviewContainer.cpp @@ -29,6 +29,7 @@ #include "unity-shared/PreviewStyle.h" #include "PreviewNavigator.h" #include <boost/math/constants/constants.hpp> +#include "config.h" namespace unity { @@ -58,13 +59,22 @@ const std::string ANIMATION_IDLE = "animation-idle"; class PreviewContent : public nux::Layout { public: - PreviewContent(const PreviewContainer*const parent) - : progress_(0.0) + PreviewContent(PreviewContainer*const parent) + : parent_(parent) + , progress_(0.0) , animating_(false) - , parent_(parent) {} + , waiting_preview_(false) + , rotation_(0.0) + { + Style& style = previews::Style::Instance(); + + spin_= style.GetSearchSpinIcon(256); + } void PushPreview(previews::Preview::Ptr preview, Navigation direction) { + StopPreviewWait(); + if (preview) { AddView(preview.GetPointer()); @@ -172,6 +182,43 @@ public: } } + void StartPreviewWait() + { + preview_wait_timer_.reset(new glib::Timeout(300, [&] () { + + if (waiting_preview_) + return false; + + waiting_preview_ = true; + + rotate_matrix_.Rotate_z(0.0f); + rotation_ = 0.0f; + parent_->QueueDraw(); + return false; + })); + } + + void StopPreviewWait() + { + preview_wait_timer_.reset(); + waiting_preview_ = false; + parent_->QueueDraw(); + } + + bool OnFrameTimeout() + { + frame_timeout_.reset(); + rotation_ += 0.1f; + + if (rotation_ >= 360.0f) + rotation_ = 0.0f; + + rotate_matrix_.Rotate_z(rotation_); + parent_->QueueDraw(); + + return false; + } + // Dont draw in process draw. this is so we can control the z order. void ProcessDraw(nux::GraphicsEngine& gfx_engine, bool force_draw) { @@ -182,6 +229,57 @@ public: if (swipe_.preview && swipe_.preview->IsVisible()) { swipe_.preview->ProcessDraw(gfx_engine, force_draw); } if (current_preview_ && current_preview_->IsVisible()) { current_preview_->ProcessDraw(gfx_engine, force_draw); } + + if (waiting_preview_) + { + nux::Geometry const& base = GetGeometry(); + + unsigned int alpha, src, dest = 0; + gfx_engine.GetRenderStates().GetBlend(alpha, src, dest); + gfx_engine.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + + nux::TexCoordXForm texxform; + texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); + texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT); + texxform.min_filter = nux::TEXFILTER_LINEAR; + texxform.mag_filter = nux::TEXFILTER_LINEAR; + + nux::Geometry spin_geo(base.x + ((base.width - spin_->GetWidth()) / 2), + base.y + ((base.height - spin_->GetHeight()) / 2), + spin_->GetWidth(), + spin_->GetHeight()); + // Geometry (== Rect) uses integers which were rounded above, + // hence an extra 0.5 offset for odd sizes is needed + // because pure floating point is not being used. + int spin_offset_w = !(base.width % 2) ? 0 : 1; + int spin_offset_h = !(base.height % 2) ? 0 : 1; + + gfx_engine.PushModelViewMatrix(nux::Matrix4::TRANSLATE(-spin_geo.x - (spin_geo.width + spin_offset_w) / 2.0f, + -spin_geo.y - (spin_geo.height + spin_offset_h) / 2.0f, 0)); + gfx_engine.PushModelViewMatrix(rotate_matrix_); + gfx_engine.PushModelViewMatrix(nux::Matrix4::TRANSLATE(spin_geo.x + (spin_geo.width + spin_offset_w) / 2.0f, + spin_geo.y + (spin_geo.height + spin_offset_h) / 2.0f, 0)); + + gfx_engine.QRP_1Tex(spin_geo.x, + spin_geo.y, + spin_geo.width, + spin_geo.height, + spin_->GetDeviceTexture(), + texxform, + nux::color::White); + + gfx_engine.PopModelViewMatrix(); + gfx_engine.PopModelViewMatrix(); + gfx_engine.PopModelViewMatrix(); + + gfx_engine.GetRenderStates().SetBlend(alpha, src, dest); + + if (!frame_timeout_) + { + frame_timeout_.reset(new glib::Timeout(22, sigc::mem_fun(this, &PreviewContent::OnFrameTimeout))); + } + } + _queued_draw = false; } @@ -189,8 +287,10 @@ public: sigc::signal<void> continue_navigation; sigc::signal<void> end_navigation; -protected: private: + PreviewContainer*const parent_; + + // Swipe animation struct PreviewSwipe { Navigation direction; @@ -198,14 +298,22 @@ private: void reset() { preview.Release(); } }; - std::queue<PreviewSwipe> push_preview_; - previews::Preview::Ptr current_preview_; + std::queue<PreviewSwipe> push_preview_; PreviewSwipe swipe_; float progress_; bool animating_; - const PreviewContainer*const parent_; + + // wait animation + glib::Source::UniquePtr preview_wait_timer_; + glib::Source::UniquePtr _frame_timeout; + bool waiting_preview_; + nux::ObjectPtr<nux::BaseTexture> spin_; + + glib::Source::UniquePtr frame_timeout_; + nux::Matrix4 rotate_matrix_; + float rotation_; }; NUX_IMPLEMENT_OBJECT_TYPE(PreviewContainer); @@ -214,6 +322,7 @@ PreviewContainer::PreviewContainer(NUX_FILE_LINE_DECL) : View(NUX_FILE_LINE_PARAM) , content_layout_(nullptr) , nav_disabled_(Navigation::NONE) + , last_calc_height_(0) , navigation_progress_speed_(0.0) , navigation_count_(0) { @@ -262,12 +371,13 @@ void PreviewContainer::SetupViews() layout_ = new nux::HLayout(); SetLayout(layout_); + layout_->AddSpace(0, 0); nav_left_ = new PreviewNavigator(Orientation::LEFT, NUX_TRACKER_LOCATION); nav_left_->SetMinimumWidth(style.GetNavigatorWidth()); nav_left_->SetMaximumWidth(style.GetNavigatorWidth()); nav_left_->activated.connect([&]() { navigate_left.emit(); }); - layout_->AddView(nav_left_, 0); + layout_->AddView(nav_left_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); content_layout_ = new PreviewContent(this); layout_->AddLayout(content_layout_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); @@ -276,7 +386,9 @@ void PreviewContainer::SetupViews() nav_right_->SetMinimumWidth(style.GetNavigatorWidth()); nav_right_->SetMaximumWidth(style.GetNavigatorWidth()); nav_right_->activated.connect([&]() { navigate_right.emit(); }); - layout_->AddView(nav_right_, 0); + layout_->AddView(nav_right_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); + + layout_->AddSpace(0, 0); content_layout_->start_navigation.connect([&]() { @@ -301,6 +413,9 @@ void PreviewContainer::SetupViews() navigation_count_ = 0; navigation_progress_speed_ = 0; }); + + navigate_right.connect( [&]() { content_layout_->StartPreviewWait(); } ); + navigate_left.connect( [&]() { content_layout_->StartPreviewWait(); } ); } void PreviewContainer::Draw(nux::GraphicsEngine& gfx_engine, bool force_draw) @@ -334,6 +449,32 @@ void PreviewContainer::DrawContent(nux::GraphicsEngine& gfx_engine, bool force_d gfx_engine.PopClippingRectangle(); } +void PreviewContainer::PreLayoutManagement() +{ + previews::Style& style = previews::Style::Instance(); + nux::Geometry const& geo = GetGeometry(); + + int available_preview_width = MAX(1, geo.width - nav_left_->GetGeometry().width - nav_right_->GetGeometry().width); + int aspect_altered_height = available_preview_width / style.GetPreviewAspectRatio(); + + aspect_altered_height = CLAMP(aspect_altered_height, 1, geo.height); + if (last_calc_height_ != aspect_altered_height) + { + last_calc_height_ = aspect_altered_height; + + content_layout_->SetMinimumHeight(aspect_altered_height); + content_layout_->SetMaximumHeight(aspect_altered_height); + + nav_left_->SetMinimumHeight(aspect_altered_height); + nav_left_->SetMaximumHeight(aspect_altered_height); + + nav_right_->SetMinimumHeight(aspect_altered_height); + nav_right_->SetMaximumHeight(aspect_altered_height); + } + + View::PreLayoutManagement(); +} + bool PreviewContainer::AnimationInProgress() { // short circuit to avoid unneeded calculations @@ -361,18 +502,6 @@ static float easeInOutQuart(float t) } } -// static float easeInOutCubic(float t) -// { -// t = CLAMP(t, 0.0, 1.0); -// t*=2.0f; -// if(t < 1.0f) { -// return 0.5f*pow(t, 3); -// } else { -// t -= 2.0f; -// return 0.5f*(pow(t, 3) + 2); -// } -// } - float PreviewContainer::GetSwipeAnimationProgress(struct timespec const& current) const { int time_delta = TimeUtil::TimeDelta(¤t, &last_progress_time_); diff --git a/dash/previews/PreviewContainer.h b/dash/previews/PreviewContainer.h index 13a93b4d0..4a975d158 100644 --- a/dash/previews/PreviewContainer.h +++ b/dash/previews/PreviewContainer.h @@ -79,6 +79,7 @@ public: protected: void Draw(nux::GraphicsEngine& gfx_engine, bool force_draw); void DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw); + void PreLayoutManagement(); nux::Area* KeyNavIteration(nux::KeyNavDirection direction); @@ -100,6 +101,7 @@ private: PreviewNavigator* nav_right_; PreviewContent* content_layout_; Navigation nav_disabled_; + int last_calc_height_; // Animation struct timespec last_progress_time_; diff --git a/dash/previews/PreviewInfoHintWidget.cpp b/dash/previews/PreviewInfoHintWidget.cpp index 447bc3f55..9e0e4336d 100644 --- a/dash/previews/PreviewInfoHintWidget.cpp +++ b/dash/previews/PreviewInfoHintWidget.cpp @@ -44,11 +44,9 @@ const int layout_spacing = 12; NUX_IMPLEMENT_OBJECT_TYPE(PreviewInfoHintWidget); -PreviewInfoHintWidget::PreviewInfoHintWidget(dash::Preview::Ptr preview_model, int icon_size, bool visible_icons, bool condensed_format) +PreviewInfoHintWidget::PreviewInfoHintWidget(dash::Preview::Ptr preview_model, int icon_size) : View(NUX_TRACKER_LOCATION) , icon_size_(icon_size) -, condensed_format_(condensed_format) -, visible_icons_(visible_icons) , preview_model_(preview_model) { SetupViews(); @@ -58,20 +56,6 @@ PreviewInfoHintWidget::~PreviewInfoHintWidget() { } -void PreviewInfoHintWidget::SetVisibleIcons(bool visible) -{ - visible_icons_ = visible; - SetupViews(); - QueueDraw(); -} - -void PreviewInfoHintWidget::SetCondensedFormat(bool condensed) -{ - condensed_format_ = condensed; - SetupViews(); - QueueDraw(); -} - void PreviewInfoHintWidget::Draw(nux::GraphicsEngine& gfx_engine, bool force_draw) { } @@ -168,28 +152,16 @@ void PreviewInfoHintWidget::SetupViews() nux::HLayout* hint_layout = new nux::HLayout(); hint_layout->SetSpaceBetweenChildren(layout_spacing); - if (visible_icons_) - { - IconTexture* info_icon = new IconTexture(info_hint->icon_hint, icon_size_); - info_icon->SetMinimumSize(icon_size_, icon_size_); - info_icon->SetVisible(true); - hint_layout->AddView(info_icon, 0); - } - StaticCairoTextPtr info_name; if (!info_hint->display_name.empty()) { std::string tmp_display_name = info_hint->display_name; - if (condensed_format_) { tmp_display_name += ":"; } + tmp_display_name += ":"; info_name = new nux::StaticCairoText(tmp_display_name, NUX_TRACKER_LOCATION); - info_name->SetFont(condensed_format_ ? style.info_hint_bold_font() : style.info_hint_font()); + info_name->SetFont(style.info_hint_bold_font()); info_name->SetLines(-1); - if (!condensed_format_) - { - info_name->SetMinimumWidth(style.GetInfoHintNameWidth()); - info_name->SetMaximumWidth(style.GetInfoHintNameWidth()); - } + info_name->SetTextAlignment(nux::StaticCairoText::NUX_ALIGN_RIGHT); hint_layout->AddView(info_name.GetPointer(), 0, nux::MINOR_POSITION_CENTER); } @@ -213,29 +185,42 @@ void PreviewInfoHintWidget::PreLayoutManagement() previews::Style& style = previews::Style::Instance(); nux::Geometry const& geo = GetGeometry(); + int info_hint_width = 0; for (InfoHint const& info_hint : info_hints_) { - int max_info_value_width = geo.width; - if (visible_icons_) + int width = style.GetInfoHintNameMinimumWidth(); + if (info_hint.first) { - max_info_value_width -= icon_size_; - max_info_value_width -= layout_spacing; + width = info_hint.first->GetTextExtents().width; + + if (width < style.GetInfoHintNameMinimumWidth()) + width = style.GetInfoHintNameMinimumWidth(); + else if (width > style.GetInfoHintNameMaximumWidth()) + width = style.GetInfoHintNameMaximumWidth(); } - if (info_hint.first) + + if (info_hint_width < width) { - if (condensed_format_) - { - max_info_value_width -= info_hint.first->GetTextExtents().width; - } - else - { - max_info_value_width -= style.GetInfoHintNameWidth(); - } - max_info_value_width -= layout_spacing; + info_hint_width = width; } + } + + int info_value_width = geo.width; + info_value_width -= layout_spacing; + info_value_width -= info_hint_width; + for (InfoHint const& info_hint : info_hints_) + { + if (info_hint.first) + { + info_hint.first->SetMinimumWidth(info_hint_width); + info_hint.first->SetMaximumWidth(info_hint_width); + } if (info_hint.second) - info_hint.second->SetMaximumWidth(max_info_value_width); + { + info_hint.second->SetMinimumWidth(info_value_width); + info_hint.second->SetMaximumWidth(info_value_width); + } } View::PreLayoutManagement(); diff --git a/dash/previews/PreviewInfoHintWidget.h b/dash/previews/PreviewInfoHintWidget.h index ad7b3eadf..72591c22f 100644 --- a/dash/previews/PreviewInfoHintWidget.h +++ b/dash/previews/PreviewInfoHintWidget.h @@ -46,12 +46,9 @@ public: typedef nux::ObjectPtr<PreviewInfoHintWidget> Ptr; NUX_DECLARE_OBJECT_TYPE(PreviewInfoHintWidget, nux::View); - PreviewInfoHintWidget(dash::Preview::Ptr preview_model, int icon_size, bool visible_icons = true, bool condensed_format = false); + PreviewInfoHintWidget(dash::Preview::Ptr preview_model, int icon_size); virtual ~PreviewInfoHintWidget(); - void SetVisibleIcons(bool visible); - void SetCondensedFormat(bool condensed); - // From debug::Introspectable std::string GetName() const; void AddProperties(GVariantBuilder* builder); @@ -72,8 +69,6 @@ protected: protected: int icon_size_; - bool condensed_format_; - bool visible_icons_; typedef nux::ObjectPtr<nux::StaticCairoText> StaticCairoTextPtr; typedef std::pair<StaticCairoTextPtr, StaticCairoTextPtr> InfoHint; diff --git a/dash/previews/StandaloneApplicationPreview.cpp b/dash/previews/StandaloneApplicationPreview.cpp index bae07ecb3..f9873f0fa 100644 --- a/dash/previews/StandaloneApplicationPreview.cpp +++ b/dash/previews/StandaloneApplicationPreview.cpp @@ -127,6 +127,7 @@ public: previews::PreviewContainer::Ptr container_; nux::Layout *layout_; int nav_iter; + glib::Source::UniquePtr preview_wait_timer_; }; TestRunner::TestRunner () @@ -235,43 +236,49 @@ The service allows users to communicate with peers by voice, video, and instant void TestRunner::NavLeft() { - std::stringstream app_name; - app_name << "Title " << --nav_iter; + preview_wait_timer_.reset(new glib::Timeout(2000, [&] () { - const char* subtitle = "Version 3.2, Size 32 MB"; - const char* description = "Skype is a proprietary voice-over-Internet Protocol service and software application originally created by Niklas Zennström and Janus Friis in 2003, and owned by Microsoft since 2011. \ -The service allows users to communicate with peers by voice, video, and instant messaging over the Internet. Phone calls may be placed to recipients on the traditional telephone networks. Calls to other users within the Skype service are free of charge, while calls to landline telephones and mobile phones are charged via a debit-based user account system."; - // creates a generic preview object - glib::Object<GIcon> iconHint1(g_icon_new_for_string("/usr/share/unity/5/lens-nav-music.svg", NULL)); - glib::Object<GIcon> iconHint2(g_icon_new_for_string("/usr/share/unity/5/lens-nav-home.svg", NULL)); - glib::Object<GIcon> iconHint3(g_icon_new_for_string("/usr/share/unity/5/lens-nav-people.svg", NULL)); + std::stringstream app_name; + app_name << "Title " << --nav_iter; - glib::Object<UnityProtocolPreview> proto_obj(UNITY_PROTOCOL_PREVIEW(unity_protocol_application_preview_new())); + const char* subtitle = "Version 3.2, Size 32 MB"; + const char* description = "Skype is a proprietary voice-over-Internet Protocol service and software application originally created by Niklas Zennström and Janus Friis in 2003, and owned by Microsoft since 2011. \ + The service allows users to communicate with peers by voice, video, and instant messaging over the Internet. Phone calls may be placed to recipients on the traditional telephone networks. Calls to other users within the Skype service are free of charge, while calls to landline telephones and mobile phones are charged via a debit-based user account system."; + // creates a generic preview object + glib::Object<GIcon> iconHint1(g_icon_new_for_string("/usr/share/unity/5/lens-nav-music.svg", NULL)); + glib::Object<GIcon> iconHint2(g_icon_new_for_string("/usr/share/unity/5/lens-nav-home.svg", NULL)); + glib::Object<GIcon> iconHint3(g_icon_new_for_string("/usr/share/unity/5/lens-nav-people.svg", NULL)); - unity_protocol_application_preview_set_app_icon(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), g_icon_new_for_string("/home/nick/SkypeIcon.png", NULL)); - unity_protocol_application_preview_set_license(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), "Proprietary"); - unity_protocol_application_preview_set_copyright(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), "(c) Skype 2012"); - unity_protocol_application_preview_set_last_update(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), "11th Apr 2012"); - unity_protocol_application_preview_set_rating(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), 0.8); - unity_protocol_application_preview_set_num_ratings(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), 1223); + glib::Object<UnityProtocolPreview> proto_obj(UNITY_PROTOCOL_PREVIEW(unity_protocol_application_preview_new())); - unity_protocol_preview_set_image_source_uri(proto_obj, "file:///home/nick/Skype.png"); - unity_protocol_preview_set_title(proto_obj, app_name.str().c_str()); - unity_protocol_preview_set_subtitle(proto_obj, subtitle); - unity_protocol_preview_set_description(proto_obj, description); - unity_protocol_preview_add_action(proto_obj, "uninstall", "Uninstall", iconHint1, 0); - unity_protocol_preview_add_action(proto_obj, "launch", "Launch", iconHint2, 0); - unity_protocol_preview_add_info_hint(proto_obj, "time", "Total time", iconHint1, g_variant_new("s", "16 h 34miin 45sec")); - unity_protocol_preview_add_info_hint(proto_obj, "energy", "Energy", iconHint2, g_variant_new("s", "58.07 mWh")); - unity_protocol_preview_add_info_hint(proto_obj, "load", "CPU Load", iconHint3, g_variant_new("i", 22)); - glib::Variant v(dee_serializable_serialize(DEE_SERIALIZABLE(proto_obj.RawPtr())), - glib::StealRef()); + unity_protocol_application_preview_set_app_icon(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), g_icon_new_for_string("/home/nick/SkypeIcon.png", NULL)); + unity_protocol_application_preview_set_license(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), "Proprietary"); + unity_protocol_application_preview_set_copyright(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), "(c) Skype 2012"); + unity_protocol_application_preview_set_last_update(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), "11th Apr 2012"); + unity_protocol_application_preview_set_rating(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), 0.8); + unity_protocol_application_preview_set_num_ratings(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), 1223); - dash::Preview::Ptr preview_model(dash::Preview::PreviewForVariant(v)); - container_->Preview(preview_model, previews::Navigation::LEFT); + unity_protocol_preview_set_image_source_uri(proto_obj, "file:///home/nick/Skype.png"); + unity_protocol_preview_set_title(proto_obj, app_name.str().c_str()); + unity_protocol_preview_set_subtitle(proto_obj, subtitle); + unity_protocol_preview_set_description(proto_obj, description); + unity_protocol_preview_add_action(proto_obj, "uninstall", "Uninstall", iconHint1, 0); + unity_protocol_preview_add_action(proto_obj, "launch", "Launch", iconHint2, 0); + unity_protocol_preview_add_info_hint(proto_obj, "time", "Total time", iconHint1, g_variant_new("s", "16 h 34miin 45sec")); + unity_protocol_preview_add_info_hint(proto_obj, "energy", "Energy", iconHint2, g_variant_new("s", "58.07 mWh")); + unity_protocol_preview_add_info_hint(proto_obj, "load", "CPU Load", iconHint3, g_variant_new("i", 22)); + + glib::Variant v(dee_serializable_serialize(DEE_SERIALIZABLE(proto_obj.RawPtr())), + glib::StealRef()); + + dash::Preview::Ptr preview_model(dash::Preview::PreviewForVariant(v)); + container_->Preview(preview_model, previews::Navigation::LEFT); + + return false; + })); } void TestRunner::InitWindowThread(nux::NThread* thread, void* InitData) |
