Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: chrome/browser/ui/libgtk2ui/gtk2_status_icon.cc

Issue 291893009: Fall back to X11 system tray icons if libappindicator is not available (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/libgtk2ui/gtk2_status_icon.h ('k') | chrome/browser/ui/libgtk2ui/gtk2_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/libgtk2ui/gtk2_status_icon.h"
6
7 #include <gtk/gtk.h>
8
9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/ui/libgtk2ui/app_indicator_icon_menu.h"
11 #include "chrome/browser/ui/libgtk2ui/skia_utils_gtk2.h"
12 #include "ui/base/models/menu_model.h"
13 #include "ui/gfx/image/image_skia.h"
14
15 namespace libgtk2ui {
16
17 Gtk2StatusIcon::Gtk2StatusIcon(const gfx::ImageSkia& image,
18 const base::string16& tool_tip) {
19 GdkPixbuf* pixbuf = GdkPixbufFromSkBitmap(*image.bitmap());
20 gtk_status_icon_ = gtk_status_icon_new_from_pixbuf(pixbuf);
21 g_object_unref(pixbuf);
22
23 g_signal_connect(gtk_status_icon_, "activate", G_CALLBACK(OnClickThunk),
24 this);
25 g_signal_connect(gtk_status_icon_, "popup_menu",
26 G_CALLBACK(OnContextMenuRequestedThunk), this);
27 SetToolTip(tool_tip);
28 }
29
30 Gtk2StatusIcon::~Gtk2StatusIcon() {
31 g_object_unref(gtk_status_icon_);
32 }
33
34 void Gtk2StatusIcon::SetImage(const gfx::ImageSkia& image) {
35 GdkPixbuf* pixbuf = GdkPixbufFromSkBitmap(*image.bitmap());
36 gtk_status_icon_set_from_pixbuf(gtk_status_icon_, pixbuf);
37 g_object_unref(pixbuf);
38 }
39
40 void Gtk2StatusIcon::SetPressedImage(const gfx::ImageSkia& image) {
41 // Ignore pressed images, since the standard on Linux is to not highlight
42 // pressed status icons.
43 }
44
45 void Gtk2StatusIcon::SetToolTip(const base::string16& tool_tip) {
46 gtk_status_icon_set_tooltip_text(gtk_status_icon_,
47 base::UTF16ToUTF8(tool_tip).c_str());
48 }
49
50 void Gtk2StatusIcon::UpdatePlatformContextMenu(ui::MenuModel* model) {
51 menu_.reset();
52 if (model)
53 menu_.reset(new AppIndicatorIconMenu(model));
54 }
55
56 void Gtk2StatusIcon::RefreshPlatformContextMenu() {
57 if (menu_.get())
58 menu_->Refresh();
59 }
60
61 void Gtk2StatusIcon::OnClick(GtkStatusIcon* status_icon) {
62 if (delegate())
63 delegate()->OnClick();
64 }
65
66 void Gtk2StatusIcon::OnContextMenuRequested(GtkStatusIcon* status_icon,
67 guint button,
68 guint32 activate_time) {
69 if (menu_.get()) {
70 gtk_menu_popup(menu_->GetGtkMenu(),
71 NULL,
72 NULL,
73 gtk_status_icon_position_menu,
74 gtk_status_icon_,
75 button,
76 activate_time);
77 }
78 }
79
80 } // namespace libgtk2ui
OLDNEW
« no previous file with comments | « chrome/browser/ui/libgtk2ui/gtk2_status_icon.h ('k') | chrome/browser/ui/libgtk2ui/gtk2_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698