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

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

Issue 18334003: Linux status icon for Ubuntu Unity (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: file restored Created 7 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h" 5 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/environment.h" 10 #include "base/environment.h"
11 #include "base/i18n/rtl.h" 11 #include "base/i18n/rtl.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/nix/mime_util_xdg.h" 13 #include "base/nix/mime_util_xdg.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/strings/stringprintf.h"
15 #include "chrome/browser/themes/theme_properties.h" 16 #include "chrome/browser/themes/theme_properties.h"
17 #include "chrome/browser/ui/libgtk2ui/app_indicator_icon.h"
16 #include "chrome/browser/ui/libgtk2ui/chrome_gtk_frame.h" 18 #include "chrome/browser/ui/libgtk2ui/chrome_gtk_frame.h"
17 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" 19 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h"
18 #include "chrome/browser/ui/libgtk2ui/native_theme_gtk2.h" 20 #include "chrome/browser/ui/libgtk2ui/native_theme_gtk2.h"
19 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h" 21 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h"
20 #include "chrome/browser/ui/libgtk2ui/skia_utils_gtk2.h" 22 #include "chrome/browser/ui/libgtk2ui/skia_utils_gtk2.h"
21 #include "chrome/browser/ui/libgtk2ui/unity_service.h" 23 #include "chrome/browser/ui/libgtk2ui/unity_service.h"
22 #include "grit/theme_resources.h" 24 #include "grit/theme_resources.h"
23 #include "grit/ui_resources.h" 25 #include "grit/ui_resources.h"
24 #include "third_party/skia/include/core/SkBitmap.h" 26 #include "third_party/skia/include/core/SkBitmap.h"
25 #include "third_party/skia/include/core/SkCanvas.h" 27 #include "third_party/skia/include/core/SkCanvas.h"
(...skipping 16 matching lines...) Expand all
42 // - Render and inject the button overlay from the gtk theme. 44 // - Render and inject the button overlay from the gtk theme.
43 // - Render and inject the omnibox background. 45 // - Render and inject the omnibox background.
44 // - Listen for the "style-set" signal on |fake_frame_| and recreate theme 46 // - Listen for the "style-set" signal on |fake_frame_| and recreate theme
45 // colors and images. 47 // colors and images.
46 // - Allow not using the theme. 48 // - Allow not using the theme.
47 // - Make sure to test with a light on dark theme, too. 49 // - Make sure to test with a light on dark theme, too.
48 // - Everything else that we're not doing. 50 // - Everything else that we're not doing.
49 51
50 namespace { 52 namespace {
51 53
54 // Prefix for app indicator ids
55 const char kAppIndicatorIdPrefix[] = "chrome_app_indicator_";
56
57 // Number of app indicators used (used as part of app-indicator id).
58 int indicators_count;
59
52 // The size of the rendered toolbar image. 60 // The size of the rendered toolbar image.
53 const int kToolbarImageWidth = 64; 61 const int kToolbarImageWidth = 64;
54 const int kToolbarImageHeight = 128; 62 const int kToolbarImageHeight = 128;
55 63
56 // How much to tint the GTK+ color lighter at the top of the window. 64 // How much to tint the GTK+ color lighter at the top of the window.
57 const color_utils::HSL kGtkFrameShift = { -1, -1, 0.58 }; 65 const color_utils::HSL kGtkFrameShift = { -1, -1, 0.58 };
58 66
59 // How much to tint the GTK+ color when an explicit frame color hasn't been 67 // How much to tint the GTK+ color when an explicit frame color hasn't been
60 // specified. 68 // specified.
61 const color_utils::HSL kDefaultFrameShift = { -1, -1, 0.4 }; 69 const color_utils::HSL kDefaultFrameShift = { -1, -1, 0.4 };
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 // broadcast new theme images and colors. Only realized widgets have style 305 // broadcast new theme images and colors. Only realized widgets have style
298 // properties, too, which we query for some colors. 306 // properties, too, which we query for some colors.
299 gtk_widget_realize(fake_frame_); 307 gtk_widget_realize(fake_frame_);
300 gtk_widget_realize(fake_window_); 308 gtk_widget_realize(fake_window_);
301 // TODO: Also listen for "style-set" on the fake frame. 309 // TODO: Also listen for "style-set" on the fake frame.
302 310
303 // TODO(erg): Be lazy about generating this data and connect it to the 311 // TODO(erg): Be lazy about generating this data and connect it to the
304 // style-set signal handler. 312 // style-set signal handler.
305 LoadGtkValues(); 313 LoadGtkValues();
306 SetXDGIconTheme(); 314 SetXDGIconTheme();
315
316 indicators_count = 0;
307 } 317 }
308 318
309 Gtk2UI::~Gtk2UI() { 319 Gtk2UI::~Gtk2UI() {
310 gtk_widget_destroy(fake_window_); 320 gtk_widget_destroy(fake_window_);
311 gtk_widget_destroy(fake_frame_); 321 gtk_widget_destroy(fake_frame_);
312 fake_label_.Destroy(); 322 fake_label_.Destroy();
313 fake_entry_.Destroy(); 323 fake_entry_.Destroy();
314 324
315 ClearAllThemeData(); 325 ClearAllThemeData();
316 } 326 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 void Gtk2UI::SetDownloadCount(int count) const { 384 void Gtk2UI::SetDownloadCount(int count) const {
375 if (unity::IsRunning()) 385 if (unity::IsRunning())
376 unity::SetDownloadCount(count); 386 unity::SetDownloadCount(count);
377 } 387 }
378 388
379 void Gtk2UI::SetProgressFraction(float percentage) const { 389 void Gtk2UI::SetProgressFraction(float percentage) const {
380 if (unity::IsRunning()) 390 if (unity::IsRunning())
381 unity::SetProgressFraction(percentage); 391 unity::SetProgressFraction(percentage);
382 } 392 }
383 393
394 bool Gtk2UI::IsStatusIconSupported() const {
395 return AppIndicatorIcon::CouldOpen();
396 }
397
398 scoped_ptr<StatusIconLinux> Gtk2UI::CreateLinuxStatusIcon() const {
399 if (AppIndicatorIcon::CouldOpen()) {
400 ++indicators_count;
401 return scoped_ptr<StatusIconLinux>(new AppIndicatorIcon(
402 base::StringPrintf("%s%d", kAppIndicatorIdPrefix, indicators_count)));
403 } else {
404 return scoped_ptr<StatusIconLinux>();
405 }
406 }
407
384 ui::SelectFileDialog* Gtk2UI::CreateSelectFileDialog( 408 ui::SelectFileDialog* Gtk2UI::CreateSelectFileDialog(
385 ui::SelectFileDialog::Listener* listener, 409 ui::SelectFileDialog::Listener* listener,
386 ui::SelectFilePolicy* policy) const { 410 ui::SelectFilePolicy* policy) const {
387 return SelectFileDialogImpl::Create(listener, policy); 411 return SelectFileDialogImpl::Create(listener, policy);
388 } 412 }
389 413
390 void Gtk2UI::GetScrollbarColors(GdkColor* thumb_active_color, 414 void Gtk2UI::GetScrollbarColors(GdkColor* thumb_active_color,
391 GdkColor* thumb_inactive_color, 415 GdkColor* thumb_inactive_color,
392 GdkColor* track_color) { 416 GdkColor* track_color) {
393 const GdkColor* theme_thumb_active = NULL; 417 const GdkColor* theme_thumb_active = NULL;
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 1034
1011 void Gtk2UI::ClearAllThemeData() { 1035 void Gtk2UI::ClearAllThemeData() {
1012 gtk_images_.clear(); 1036 gtk_images_.clear();
1013 } 1037 }
1014 1038
1015 } // namespace libgtk2ui 1039 } // namespace libgtk2ui
1016 1040
1017 ui::LinuxUI* BuildGtk2UI() { 1041 ui::LinuxUI* BuildGtk2UI() {
1018 return new libgtk2ui::Gtk2UI; 1042 return new libgtk2ui::Gtk2UI;
1019 } 1043 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698