Merge pull request #6145 from electron/app-indicator-id

Use fixed ID for app indicators
This commit is contained in:
Cheng Zhao 2016-06-20 08:50:16 +00:00 committed by GitHub
commit b87cf3771b

View file

@ -4,7 +4,8 @@
#include "atom/browser/ui/tray_icon_gtk.h"
#include "base/guid.h"
#include "atom/browser/browser.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/libgtk2ui/app_indicator_icon.h"
#include "chrome/browser/ui/libgtk2ui/gtk2_status_icon.h"
@ -12,6 +13,13 @@
namespace atom {
namespace {
// Number of app indicators used (used as part of app-indicator id).
int indicators_count;
} // namespace
TrayIconGtk::TrayIconGtk() {
}
@ -25,11 +33,16 @@ void TrayIconGtk::SetImage(const gfx::Image& image) {
}
base::string16 empty;
if (libgtk2ui::AppIndicatorIcon::CouldOpen())
if (libgtk2ui::AppIndicatorIcon::CouldOpen()) {
++indicators_count;
icon_.reset(new libgtk2ui::AppIndicatorIcon(
base::GenerateGUID(), image.AsImageSkia(), empty));
else
base::StringPrintf(
"%s%d", Browser::Get()->GetName().c_str(), indicators_count),
image.AsImageSkia(),
empty));
} else {
icon_.reset(new libgtk2ui::Gtk2StatusIcon(image.AsImageSkia(), empty));
}
icon_->set_delegate(this);
}