From: Cheng Zhao Date: Mon, 17 Nov 2014 09:35:51 +0000 (+0800) Subject: Enable setting icon for addUserTasks X-Git-Tag: v0.19.3~1^2~9 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=0b1b0940d23c174b5437d5cceb42ca1e62d6e2fe;p=electron.git Enable setting icon for addUserTasks --- diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index ce56c0da..d6f80724 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -35,6 +35,7 @@ using atom::Browser; namespace mate { +#if defined(OS_WIN) template<> struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Handle val, @@ -45,11 +46,15 @@ struct Converter { if (!dict.Get("program", &(out->program)) || !dict.Get("title", &(out->title))) return false; + if (dict.Get("iconPath", &(out->icon_path)) && + !dict.Get("iconIndex", &(out->icon_index))) + return false; dict.Get("arguments", &(out->arguments)); dict.Get("description", &(out->description)); return true; } }; +#endif } // namespace mate diff --git a/atom/browser/browser.h b/atom/browser/browser.h index 69f61da8..a22680ac 100644 --- a/atom/browser/browser.h +++ b/atom/browser/browser.h @@ -91,6 +91,8 @@ class Browser : public WindowListObserver { base::string16 arguments; base::string16 title; base::string16 description; + base::FilePath icon_path; + int icon_index; }; // Add a custom task to jump list. diff --git a/atom/browser/browser_win.cc b/atom/browser/browser_win.cc index 9e4db535..c8620f26 100644 --- a/atom/browser/browser_win.cc +++ b/atom/browser/browser_win.cc @@ -96,6 +96,11 @@ void Browser::AddUserTasks(const std::vector& tasks) { FAILED(link->SetDescription(task.description.c_str()))) return; + if (!task.icon_path.empty() && + FAILED(link->SetIconLocation(task.icon_path.value().c_str(), + task.icon_index))) + return; + CComQIPtr property_store = link; if (!base::win::SetStringValueForPropertyStore(property_store, PKEY_Title, task.title.c_str()))