Merge pull request #6145 from electron/app-indicator-id
Use fixed ID for app indicators
This commit is contained in:
commit
b87cf3771b
1 changed files with 17 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue