diff options
| author | Nick Dedekind <nicholas.dedekind@gmail.com> | 2012-08-03 12:00:02 +0100 |
|---|---|---|
| committer | Nick Dedekind <nicholas.dedekind@gmail.com> | 2012-08-03 12:00:02 +0100 |
| commit | 3688f0fea92403e112c7ffcd3e1a7d76770b951d (patch) | |
| tree | 6e538c6181fdb826c0e859b9a316a0a30ae94e01 /dash | |
| parent | 0addd40e0aeed24e75aedc9b104fc6935e1c7740 (diff) | |
| parent | 86f18578e7a28d00ff122bde876db406a9480365 (diff) | |
Merged in lp:~borabora/avani/preview-ui-standalone.ThumbGenerator
(bzr r2419.4.30)
Diffstat (limited to 'dash')
| -rw-r--r-- | dash/previews/ApplicationPreview.cpp | 7 | ||||
| -rw-r--r-- | dash/previews/CMakeLists.txt | 9 | ||||
| -rw-r--r-- | dash/previews/DBusTestRunner.h | 83 | ||||
| -rw-r--r-- | dash/previews/GenericPreview.cpp | 7 | ||||
| -rw-r--r-- | dash/previews/LensDBusTestRunner.h (renamed from dash/previews/StandaloneDBusTestRunner.h) | 61 | ||||
| -rw-r--r-- | dash/previews/MoviePreview.cpp | 6 | ||||
| -rw-r--r-- | dash/previews/Preview.cpp | 44 | ||||
| -rw-r--r-- | dash/previews/StandaloneApplicationPreview.cpp | 24 | ||||
| -rw-r--r-- | dash/previews/StandaloneMusicPreview.cpp | 8 | ||||
| -rw-r--r-- | dash/previews/StandaloneThumbnailer.cpp | 183 |
10 files changed, 342 insertions, 90 deletions
diff --git a/dash/previews/ApplicationPreview.cpp b/dash/previews/ApplicationPreview.cpp index 3ce6f2ffa..1d1f0bd5b 100644 --- a/dash/previews/ApplicationPreview.cpp +++ b/dash/previews/ApplicationPreview.cpp @@ -150,12 +150,15 @@ void ApplicationPreview::SetupViews() previews::Style& style = dash::previews::Style::Instance(); - nux::HLayout* image_data_layout = new nux::HLayout(); image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth()); image_ = new CoverArt(); - image_->SetImage(preview_model_->image.Get().RawPtr() ? g_icon_to_string(preview_model_->image.Get().RawPtr()) : ""); + std::string image_hint = preview_model_->image.Get().RawPtr() ? g_icon_to_string(preview_model_->image.Get().RawPtr()) : ""; + if (image_hint != "") + image_->SetImage(image_hint); + else + image_->GenerateImage(preview_model_->image_source_uri); image_->SetFont(style.no_preview_image_font()); ///////////////////// diff --git a/dash/previews/CMakeLists.txt b/dash/previews/CMakeLists.txt index 5a7de40a1..87fbd8c22 100644 --- a/dash/previews/CMakeLists.txt +++ b/dash/previews/CMakeLists.txt @@ -58,4 +58,11 @@ target_link_libraries (app_previews previews-lib unity-shared) # add_executable (music_previews StandaloneMusicPreview.cpp) add_dependencies (music_previews previews-lib) -target_link_libraries (music_previews previews-lib unity-shared) \ No newline at end of file +target_link_libraries (music_previews previews-lib unity-shared) + +# +# Thumbnail Standalone +# +add_executable (thumbnailer StandaloneThumbnailer.cpp) +add_dependencies (thumbnailer unity-shared) +target_link_libraries (thumbnailer unity-shared) \ No newline at end of file diff --git a/dash/previews/DBusTestRunner.h b/dash/previews/DBusTestRunner.h new file mode 100644 index 000000000..24ffe3713 --- /dev/null +++ b/dash/previews/DBusTestRunner.h @@ -0,0 +1,83 @@ +/* + * Copyright 2012 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * version 3 along with this program. If not, see + * <http://www.gnu.org/licenses/> + * + * Authored by: Nick Dedekind <nick.dedekind@canonical.com> + * + */ + +#ifndef DBUSTESTRUNNER_H +#define DBUSTESTRUNNER_H + + #include <UnityCore/GLibDBusProxy.h> + +#include <UnityCore/Preview.h> +#include <UnityCore/Lens.h> +#include <UnityCore/Results.h> +#include <NuxCore/Logger.h> + +namespace unity +{ +namespace dash +{ +namespace previews +{ +namespace +{ +nux::logging::Logger logger("unity.dash.DBusTestRunner"); +} + + +class DBusTestRunner +{ +public: + typedef std::map<std::string, unity::glib::Variant> Hints; + + DBusTestRunner(std::string const& dbus_name, std::string const& dbus_path, std::string const& interface_name) + : proxy_(nullptr) + , connected_(false) + , dbus_name_(dbus_name) + , dbus_path_(dbus_path) + { + proxy_ = new glib::DBusProxy(dbus_name, dbus_path, interface_name); + proxy_->connected.connect(sigc::mem_fun(this, &DBusTestRunner::OnProxyConnectionChanged)); + proxy_->disconnected.connect(sigc::mem_fun(this, &DBusTestRunner::OnProxyDisconnected)); + } + + virtual void OnProxyConnectionChanged() + { + LOG_DEBUG(logger) << "Dbus connection changed. connected=" << (proxy_->IsConnected() ? "true" : "false"); + } + + virtual void OnProxyDisconnected() + { + LOG_DEBUG(logger) << "Dbus disconnected"; + } + + sigc::signal<void, bool> connected; + + glib::DBusProxy* proxy_; + + bool connected_; + std::string dbus_name_; + std::string dbus_path_; +}; + + +} // namespace previews +} // namespace dash +} // namespace unity + +#endif // DBUSTESTRUNNER_H \ No newline at end of file diff --git a/dash/previews/GenericPreview.cpp b/dash/previews/GenericPreview.cpp index 9152a1de2..4c0bab5ef 100644 --- a/dash/previews/GenericPreview.cpp +++ b/dash/previews/GenericPreview.cpp @@ -144,7 +144,12 @@ void GenericPreview::SetupViews() image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth()); image_ = new CoverArt(); - image_->SetImage(preview_model_->image.Get().RawPtr() ? g_icon_to_string(preview_model_->image.Get().RawPtr()) : ""); + std::string image_hint = preview_model_->image.Get().RawPtr() ? g_icon_to_string(preview_model_->image.Get().RawPtr()) : ""; + if (image_hint != "") + image_->SetImage(image_hint); + else + image_->GenerateImage(preview_model_->image_source_uri); + image_->SetFont(style.no_preview_image_font()); ///////////////////// diff --git a/dash/previews/StandaloneDBusTestRunner.h b/dash/previews/LensDBusTestRunner.h index 6c8aa7318..0e7fce9bc 100644 --- a/dash/previews/StandaloneDBusTestRunner.h +++ b/dash/previews/LensDBusTestRunner.h @@ -18,12 +18,11 @@ * */ - #include <UnityCore/GLibDBusProxy.h> +#ifndef LENSDBUSTESTRUNNER_H +#define LENSDBUSTESTRUNNER_H -#include <UnityCore/Preview.h> -#include <UnityCore/Lens.h> -#include <UnityCore/Results.h> -#include <NuxCore/Logger.h> + +#include "DBusTestRunner.h" namespace unity { @@ -31,36 +30,24 @@ namespace dash { namespace previews { -namespace -{ -nux::logging::Logger logger("unity.dash.StandaloneDBusTestRunner"); -} - -class StandaloneDBusTestRunner +class LensDBusTestRunner : public DBusTestRunner { public: typedef std::map<std::string, unity::glib::Variant> Hints; - StandaloneDBusTestRunner(std::string const& dbus_name, std::string const& dbus_path) - : proxy_(nullptr) + LensDBusTestRunner(std::string const& dbus_name, std::string const& dbus_path, std::string const& interface_name) + : DBusTestRunner(dbus_name, dbus_path, interface_name) , results_(new Results(ModelType::REMOTE)) , results_variant_(NULL) - , connected_(false) - , dbus_name_(dbus_name) - , dbus_path_(dbus_path) { - proxy_ = new glib::DBusProxy(dbus_name, dbus_path, "com.canonical.Unity.Lens"); - proxy_->connected.connect(sigc::mem_fun(this, &StandaloneDBusTestRunner::OnProxyConnectionChanged)); - proxy_->disconnected.connect(sigc::mem_fun(this, &StandaloneDBusTestRunner::OnProxyDisconnected)); - proxy_->Connect("Changed", sigc::mem_fun(this, &StandaloneDBusTestRunner::OnChanged)); - - results_->end_transaction.connect(sigc::mem_fun(this, &StandaloneDBusTestRunner::ResultsModelUpdated)); + proxy_->Connect("Changed", sigc::mem_fun(this, &LensDBusTestRunner::OnChanged)); + results_->end_transaction.connect(sigc::mem_fun(this, &LensDBusTestRunner::ResultsModelUpdated)); } void OnProxyConnectionChanged() { - LOG_DEBUG(logger) << "Dbus connection changed. connected=" << (proxy_->IsConnected() ? "true" : "false"); + DBusTestRunner::OnProxyConnectionChanged(); if (proxy_->IsConnected()) { @@ -69,14 +56,6 @@ public: } } - void OnProxyDisconnected() - { - LOG_DEBUG(logger) << "Dbus disconnected"; - - connected_ = false; - connected.emit(connected_); - } - void OnChanged(GVariant* parameters) { glib::String dbus_path; @@ -147,7 +126,7 @@ public: g_variant_new("(sa{sv})", search_string.c_str(), &b), - sigc::mem_fun(this, &StandaloneDBusTestRunner::OnSearchFinished), + sigc::mem_fun(this, &LensDBusTestRunner::OnSearchFinished), search_cancellable_); g_variant_builder_clear(&b); @@ -190,8 +169,6 @@ public: } } - - void Preview(std::string const& uri) { LOG_DEBUG(logger) << "Previewing '" << uri << "' on '" << dbus_name_ << "'"; @@ -211,7 +188,7 @@ public: proxy_->Call("Activate", g_variant_new("(su)", uri.c_str(), UNITY_PROTOCOL_ACTION_TYPE_PREVIEW_RESULT), - sigc::mem_fun(this, &StandaloneDBusTestRunner::ActivationReply), + sigc::mem_fun(this, &LensDBusTestRunner::ActivationReply), preview_cancellable_); } @@ -250,7 +227,6 @@ public: } - sigc::signal<void, bool> connected; sigc::signal<void, std::string const&, dash::Preview::Ptr> preview_ready; sigc::signal<void, Hints const&> search_finished; @@ -276,22 +252,15 @@ protected: } - glib::DBusProxy* proxy_; glib::Object<GCancellable> preview_cancellable_; glib::Object<GCancellable> search_cancellable_; Results::Ptr results_; GVariant *results_variant_; - - bool connected_; - std::string dbus_name_; - std::string dbus_path_; }; - - - - } // namespace previews } // namespace dash -} // namespace unity \ No newline at end of file +} // namespace unity + +#endif // LENSDBUSTESTRUNNER_H \ No newline at end of file diff --git a/dash/previews/MoviePreview.cpp b/dash/previews/MoviePreview.cpp index 45a8f4a96..68fccfac8 100644 --- a/dash/previews/MoviePreview.cpp +++ b/dash/previews/MoviePreview.cpp @@ -156,7 +156,11 @@ void MoviePreview::SetupView() image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth()); CoverArt* image = new CoverArt(); - image->SetImage(preview_model_->image.Get().RawPtr() ? g_icon_to_string(preview_model_->image.Get().RawPtr()) : ""); + std::string image_hint = preview_model_->image.Get().RawPtr() ? g_icon_to_string(preview_model_->image.Get().RawPtr()) : ""; + if (image_hint != "") + image->SetImage(image_hint); + else + image->GenerateImage(preview_model_->image_source_uri); image->SetFont(style.no_preview_image_font()); ///////////////////// diff --git a/dash/previews/Preview.cpp b/dash/previews/Preview.cpp index 423ff6c8c..676cfc64e 100644 --- a/dash/previews/Preview.cpp +++ b/dash/previews/Preview.cpp @@ -53,30 +53,30 @@ previews::Preview::Ptr Preview::PreviewForModel(dash::Preview::Ptr model) return previews::Preview::Ptr(); } - // if (model->renderer_name == "preview-generic") - // { - // return Preview::Ptr(new GenericPreview(model)); - // } - // else if (model->renderer_name == "preview-application") - // { - // return Preview::Ptr(new ApplicationPreview(model)); - // } - // else if (model->renderer_name == "preview-music") - // { - // return Preview::Ptr(new MusicPreview(model)); - // } - // else if (model->renderer_name == "preview-movie") - // { - // return Preview::Ptr(new MoviePreview(model)); - // } - // // else if (renderer_name == "preview-series") - // // { - // // return Preview::Ptr(new SeriesPreview(model)); - // // } - // else + if (model->renderer_name == "preview-generic") + { + return Preview::Ptr(new GenericPreview(model)); + } + else if (model->renderer_name == "preview-application") + { + return Preview::Ptr(new ApplicationPreview(model)); + } + else if (model->renderer_name == "preview-music") + { + return Preview::Ptr(new MusicPreview(model)); + } + else if (model->renderer_name == "preview-movie") + { + return Preview::Ptr(new MoviePreview(model)); + } + // else if (renderer_name == "preview-series") // { - // LOG_WARN(logger) << "Unable to create Preview for renderer: " << model->renderer_name.Get() << "; using generic"; + // return Preview::Ptr(new SeriesPreview(model)); // } + else + { + LOG_WARN(logger) << "Unable to create Preview for renderer: " << model->renderer_name.Get() << "; using generic"; + } return Preview::Ptr(new GenericPreview(model)); } diff --git a/dash/previews/StandaloneApplicationPreview.cpp b/dash/previews/StandaloneApplicationPreview.cpp index 2904c9f84..9c513df83 100644 --- a/dash/previews/StandaloneApplicationPreview.cpp +++ b/dash/previews/StandaloneApplicationPreview.cpp @@ -33,6 +33,7 @@ #include "unity-shared/UnitySettings.h" #include "unity-shared/PreviewStyle.h" #include "unity-shared/DashStyle.h" +#include "unity-shared/ThumbnailGenerator.h" #include "Preview.h" #include "PreviewContainer.h" @@ -158,14 +159,13 @@ void TestRunner::Init () 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> icon(g_icon_new_for_string("accessories", NULL)); 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)); glib::Object<UnityProtocolPreview> proto_obj(UNITY_PROTOCOL_PREVIEW(unity_protocol_application_preview_new())); - unity_protocol_application_preview_set_app_icon(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), g_icon_new_for_string("~/SkypeIcon.png", 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"); @@ -173,11 +173,10 @@ The service allows users to communicate with peers by voice, video, and instant unity_protocol_application_preview_set_num_ratings(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), 17); - unity_protocol_preview_set_image(proto_obj, g_icon_new_for_string("~/Skype.png", NULL)); + 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_set_image(proto_obj, icon); 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")); @@ -194,7 +193,7 @@ The service allows users to communicate with peers by voice, video, and instant void TestRunner::NavRight() { - std::stringstream app_name; + std::stringstream app_name; app_name << "Title " << ++nav_iter; const char* subtitle = "Version 3.2, Size 32 MB"; @@ -202,7 +201,6 @@ void TestRunner::NavRight() 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> icon(g_icon_new_for_string("accessories", NULL)); 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)); @@ -211,18 +209,17 @@ The service allows users to communicate with peers by voice, video, and instant - unity_protocol_application_preview_set_app_icon(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), g_icon_new_for_string("SkypeIcon.png", 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.25); unity_protocol_application_preview_set_num_ratings(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), 5); - unity_protocol_preview_set_image(proto_obj, g_icon_new_for_string("Skype.png", NULL)); + 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_set_image(proto_obj, icon); 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")); @@ -238,7 +235,7 @@ The service allows users to communicate with peers by voice, video, and instant void TestRunner::NavLeft() { - std::stringstream app_name; + std::stringstream app_name; app_name << "Title " << --nav_iter; const char* subtitle = "Version 3.2, Size 32 MB"; @@ -246,7 +243,6 @@ void TestRunner::NavLeft() 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> icon(g_icon_new_for_string("accessories", NULL)); 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)); @@ -254,18 +250,17 @@ The service allows users to communicate with peers by voice, video, and instant glib::Object<UnityProtocolPreview> proto_obj(UNITY_PROTOCOL_PREVIEW(unity_protocol_application_preview_new())); - unity_protocol_application_preview_set_app_icon(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), g_icon_new_for_string("SkypeIcon.png", 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); - unity_protocol_preview_set_image(proto_obj, g_icon_new_for_string("Skype.png", NULL)); + 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_set_image(proto_obj, icon); 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")); @@ -298,6 +293,7 @@ int main(int argc, char **argv) unity::Settings settings; unity::dash::previews::Style panel_style; unity::dash::Style dash_style; + unity::ThumbnailGenerator thumbnail_generator; TestRunner *test_runner = new TestRunner (); wt = nux::CreateGUIThread(TEXT("Unity Preview"), diff --git a/dash/previews/StandaloneMusicPreview.cpp b/dash/previews/StandaloneMusicPreview.cpp index 7981bbaa8..d5f3c27ac 100644 --- a/dash/previews/StandaloneMusicPreview.cpp +++ b/dash/previews/StandaloneMusicPreview.cpp @@ -33,10 +33,11 @@ #include "unity-shared/UnitySettings.h" #include "unity-shared/PreviewStyle.h" #include "unity-shared/DashStyle.h" +#include "unity-shared/ThumbnailGenerator.h" #include "Preview.h" #include "PreviewContainer.h" -#include "StandaloneDBusTestRunner.h" +#include "LensDBusTestRunner.h" #define WIDTH 972 @@ -118,7 +119,7 @@ protected: LayerPtr bg_layer_; }; -class TestRunner : public previews::StandaloneDBusTestRunner +class TestRunner : public previews::LensDBusTestRunner { public: TestRunner(std::string const& search_string); @@ -138,7 +139,7 @@ public: }; TestRunner::TestRunner (std::string const& search_string) -: StandaloneDBusTestRunner("com.canonical.Unity.Lens.Music","/com/canonical/unity/lens/music") +: LensDBusTestRunner("com.canonical.Unity.Lens.Files","/com/canonical/unity/lens/files", "com.canonical.Unity.Lens") , search_string_(search_string) , first_(true) { @@ -251,6 +252,7 @@ int main(int argc, char **argv) unity::Settings settings; unity::dash::previews::Style panel_style; unity::dash::Style dash_style; + unity::ThumbnailGenerator thumbnail_generator; TestRunner *test_runner = new TestRunner (argv[1]); wt = nux::CreateGUIThread(TEXT("Unity Preview"), diff --git a/dash/previews/StandaloneThumbnailer.cpp b/dash/previews/StandaloneThumbnailer.cpp new file mode 100644 index 000000000..80951083b --- /dev/null +++ b/dash/previews/StandaloneThumbnailer.cpp @@ -0,0 +1,183 @@ +/* + * Copyright 2012 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * version 3 along with this program. If not, see + * <http://www.gnu.org/licenses/> + * + * Authored by: Nick Dedekind <nick.dedekind@canonical.com> + * + */ +#include <gtk/gtk.h> + +#include "Nux/Nux.h" +#include "Nux/VLayout.h" +#include "Nux/SystemThread.h" +#include <Nux/Layout.h> +#include <NuxCore/Logger.h> +#include <UnityCore/Variant.h> + +#include "DBusTestRunner.h" + + +#define WIDTH 500 +#define HEIGHT 500 + +using namespace unity; +using namespace unity::dash; + +namespace +{ +nux::logging::Logger logger("unity.dash.StandaloneThumbnailer"); +} + + +class TestRunner : public previews::DBusTestRunner +{ +public: + TestRunner(std::string const& thumnail_uri); + ~TestRunner (); + + static void InitWindowThread (nux::NThread* thread, void* InitData); + void Init (); + + void OnProxyConnectionChanged(); + + void OnGetSupported(GVariant* parameters); + void OnThumbnailReady(GVariant* parameters); + void OnThumbnailStarted(GVariant* parameters); + void OnThumbnailFinished(GVariant* parameters); + void OnThumbnailError(GVariant* parameters); + + std::string thumnail_uri_; +}; + +TestRunner::TestRunner (std::string const& thumnail_uri) +: DBusTestRunner("org.freedesktop.thumbnails.Thumbnailer1","/org/freedesktop/thumbnails/Thumbnailer1", "org.freedesktop.thumbnails.Thumbnailer1") +, thumnail_uri_(thumnail_uri) +{ + proxy_->Connect("Ready", sigc::mem_fun(this, &TestRunner::OnThumbnailReady)); + proxy_->Connect("Started", sigc::mem_fun(this, &TestRunner::OnThumbnailStarted)); + proxy_->Connect("Finished", sigc::mem_fun(this, &TestRunner::OnThumbnailFinished)); + proxy_->Connect("Error", sigc::mem_fun(this, &TestRunner::OnThumbnailError)); +} + +TestRunner::~TestRunner () +{ +} + +void TestRunner::Init () +{ +} + +void TestRunner::OnProxyConnectionChanged() +{ + DBusTestRunner::OnProxyConnectionChanged(); + + if (proxy_->IsConnected()) + { + GVariantBuilder *builder_uri = g_variant_builder_new (G_VARIANT_TYPE ("as")); + g_variant_builder_add (builder_uri, "s", thumnail_uri_.c_str()); + GVariantBuilder *builder_mime = g_variant_builder_new (G_VARIANT_TYPE ("as")); + g_variant_builder_add (builder_mime, "s", "video/ogg"); + GVariant *value = g_variant_new ("(asasssu)", builder_uri, builder_mime, "xxlarge", "default", 0); + + printf("type: %s\n", g_variant_get_type_string(value)); + + g_variant_builder_unref (builder_uri); + g_variant_builder_unref (builder_mime); + + proxy_->Call("Queue", value, + sigc::mem_fun(this, &TestRunner::OnGetSupported), NULL); + } +} + +void TestRunner::OnThumbnailReady(GVariant* parameters) +{ + LOG_INFO(logger) << "Thumbnail ready"; + + GVariantIter *thumbnail_iter; + guint handle; + g_variant_get(parameters, "(uas)", &handle, &thumbnail_iter); + + gchar *str; + while (g_variant_iter_loop (thumbnail_iter, "s", &str)) + g_print ("thumbnail @ %s\n", str); + g_variant_iter_free (thumbnail_iter); +} + +void TestRunner::OnThumbnailStarted(GVariant* parameters) +{ + LOG_INFO(logger) << "Thumbnail started"; +} + +void TestRunner::OnThumbnailFinished(GVariant* parameters) +{ + LOG_INFO(logger) << "Thumbnail finished"; +} + +void TestRunner::OnThumbnailError(GVariant* parameters) +{ + GVariantIter *thumbnail_iter; + guint handle; + gint error_code; + glib::String message; + g_variant_get(parameters, "(uasis)", &handle, &thumbnail_iter, &error_code, &message); + g_variant_iter_free (thumbnail_iter); + + + LOG_INFO(logger) << "Thumbnail error: " << message; +} + +void TestRunner::OnGetSupported(GVariant* parameters) +{ + LOG_INFO(logger) << "OnGetSupported return"; + + printf("return type: %s\n", g_variant_get_type_string(parameters)); +} + + +void TestRunner::InitWindowThread(nux::NThread* thread, void* InitData) +{ + TestRunner *self = (TestRunner *) InitData; + self->Init (); +} + +int main(int argc, char **argv) +{ + nux::WindowThread* wt = NULL; + + gtk_init (&argc, &argv); + + if (argc < 2) + { + printf("Usage: thumbnailer URI"); + return 1; + } + + nux::NuxInitialize(0); + nux::logging::configure_logging(::getenv("UNITY_LOG_SEVERITY")); + nux::logging::Logger("unity").SetLogLevel(nux::logging::Trace); + + TestRunner *test_runner = new TestRunner (argv[1]); + wt = nux::CreateGUIThread(TEXT("Unity Preview"), + WIDTH, HEIGHT, + 0, + &TestRunner::InitWindowThread, + test_runner); + + wt->Run (NULL); + delete wt; + return 0; +} + + |
