forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Use libappindicator to show icons in all cases"
This reverts commit 05a0b26. Reason for revert: http://crbug.com/815046 - same swarming bots failing because they don't have libappindicator3. Original change's description: > Use libappindicator to show icons in all cases > > libappindicator will transparently use GtkStatusIcon if an AppIndicator > listener is not available. We will lose the left click action however, > and instead the right-click menu will be shown in all instances. > > Using libappindicator in all cases not only reduces code complexity, > but also abstracts away the complexity of determining when to use > application indicators (vs legacy icons), which is a little more > complicated with newer versions of GNOME removing the legacy icon tray, > but older versions of GNOME not showing the application indicator by > default. > > I also fixed an issue with detecting GNOME. The environment variable > value is often prefixed with the distro. > > Bug: 799144, 797332, 419673 > Change-Id: I156698f1b37ba216b4df11fa2f17dd7012c593fa > Reviewed-on: https://chromium-review.googlesource.com/911820 > Reviewed-by: Elliot Glaysher <erg@chromium.org> > Reviewed-by: Scott Graham <scottmg@chromium.org> > Reviewed-by: Gabriel Charette <gab@chromium.org> > Commit-Queue: Tim Brown <timbrown@chromium.org> > Cr-Commit-Position: refs/heads/master@{#538635} TBR=thomasanderson@chromium.org Change-Id: I61db904019740f878c4f6d6303e600b717d7888d No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: 799144, 797332, 419673 Reviewed-on: https://chromium-review.googlesource.com/934701 Reviewed-by: Ian Clelland <iclelland@chromium.org> Commit-Queue: Ian Clelland <iclelland@chromium.org> Cr-Commit-Position: refs/heads/master@{#538800}
- Loading branch information
Tim Brown
authored and
Commit Bot
committed
Feb 23, 2018
1 parent
8fb946b
commit fda9690
Showing
8 changed files
with
311 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Copyright 2014 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/ui/libgtkui/gtk_status_icon.h" | ||
|
||
#include <gtk/gtk.h> | ||
|
||
#include "base/debug/leak_annotations.h" | ||
#include "base/strings/utf_string_conversions.h" | ||
#include "chrome/browser/ui/libgtkui/app_indicator_icon_menu.h" | ||
#include "chrome/browser/ui/libgtkui/skia_utils_gtk.h" | ||
#include "ui/base/models/menu_model.h" | ||
#include "ui/gfx/image/image_skia.h" | ||
|
||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS | ||
|
||
namespace libgtkui { | ||
|
||
Gtk2StatusIcon::Gtk2StatusIcon(const gfx::ImageSkia& image, | ||
const base::string16& tool_tip) { | ||
GdkPixbuf* pixbuf = GdkPixbufFromSkBitmap(*image.bitmap()); | ||
{ | ||
#if GTK_MAJOR_VERSION == 3 | ||
// Gtk3 has a bug that leaks 384 bytes when creating a | ||
// GtkStatusIcon. It will not be fixed since the status icon was | ||
// deprectaed in version 3.14. Luckily, Chromium doesn't need to | ||
// create a status icon very often, if at all. | ||
ANNOTATE_SCOPED_MEMORY_LEAK; | ||
#endif | ||
gtk_status_icon_ = gtk_status_icon_new_from_pixbuf(pixbuf); | ||
} | ||
g_object_unref(pixbuf); | ||
|
||
g_signal_connect(gtk_status_icon_, "activate", G_CALLBACK(OnClickThunk), | ||
this); | ||
g_signal_connect(gtk_status_icon_, "popup_menu", | ||
G_CALLBACK(OnContextMenuRequestedThunk), this); | ||
SetToolTip(tool_tip); | ||
} | ||
|
||
Gtk2StatusIcon::~Gtk2StatusIcon() { | ||
gtk_status_icon_set_visible(gtk_status_icon_, FALSE); | ||
g_object_unref(gtk_status_icon_); | ||
} | ||
|
||
void Gtk2StatusIcon::SetImage(const gfx::ImageSkia& image) { | ||
GdkPixbuf* pixbuf = GdkPixbufFromSkBitmap(*image.bitmap()); | ||
gtk_status_icon_set_from_pixbuf(gtk_status_icon_, pixbuf); | ||
g_object_unref(pixbuf); | ||
} | ||
|
||
void Gtk2StatusIcon::SetToolTip(const base::string16& tool_tip) { | ||
gtk_status_icon_set_tooltip_text(gtk_status_icon_, | ||
base::UTF16ToUTF8(tool_tip).c_str()); | ||
} | ||
|
||
void Gtk2StatusIcon::UpdatePlatformContextMenu(ui::MenuModel* model) { | ||
menu_.reset(); | ||
if (model) | ||
menu_.reset(new AppIndicatorIconMenu(model)); | ||
} | ||
|
||
void Gtk2StatusIcon::RefreshPlatformContextMenu() { | ||
if (menu_.get()) | ||
menu_->Refresh(); | ||
} | ||
|
||
void Gtk2StatusIcon::OnClick(GtkStatusIcon* status_icon) { | ||
if (delegate()) | ||
delegate()->OnClick(); | ||
} | ||
|
||
void Gtk2StatusIcon::OnContextMenuRequested(GtkStatusIcon* status_icon, | ||
guint button, | ||
guint32 activate_time) { | ||
if (menu_.get()) { | ||
gtk_menu_popup(menu_->GetGtkMenu(), nullptr, nullptr, | ||
gtk_status_icon_position_menu, gtk_status_icon_, button, | ||
activate_time); | ||
} | ||
} | ||
|
||
} // namespace libgtkui |
Oops, something went wrong.