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

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: moved skia utils to skia_utils_gtk2 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 // broadcast new theme images and colors. Only realized widgets have style 304 // broadcast new theme images and colors. Only realized widgets have style
297 // properties, too, which we query for some colors. 305 // properties, too, which we query for some colors.
298 gtk_widget_realize(fake_frame_); 306 gtk_widget_realize(fake_frame_);
299 gtk_widget_realize(fake_window_); 307 gtk_widget_realize(fake_window_);
300 // TODO: Also listen for "style-set" on the fake frame. 308 // TODO: Also listen for "style-set" on the fake frame.
301 309
302 // TODO(erg): Be lazy about generating this data and connect it to the 310 // TODO(erg): Be lazy about generating this data and connect it to the
303 // style-set signal handler. 311 // style-set signal handler.
304 LoadGtkValues(); 312 LoadGtkValues();
305 SetXDGIconTheme(); 313 SetXDGIconTheme();
314
315 indicators_count = 0;
306 } 316 }
307 317
308 Gtk2UI::~Gtk2UI() { 318 Gtk2UI::~Gtk2UI() {
309 gtk_widget_destroy(fake_window_); 319 gtk_widget_destroy(fake_window_);
310 gtk_widget_destroy(fake_frame_); 320 gtk_widget_destroy(fake_frame_);
311 fake_label_.Destroy(); 321 fake_label_.Destroy();
312 fake_entry_.Destroy(); 322 fake_entry_.Destroy();
313 323
314 ClearAllThemeData(); 324 ClearAllThemeData();
315 } 325 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 void Gtk2UI::SetDownloadCount(int count) const { 383 void Gtk2UI::SetDownloadCount(int count) const {
374 if (unity::IsRunning()) 384 if (unity::IsRunning())
375 unity::SetDownloadCount(count); 385 unity::SetDownloadCount(count);
376 } 386 }
377 387
378 void Gtk2UI::SetProgressFraction(float percentage) const { 388 void Gtk2UI::SetProgressFraction(float percentage) const {
379 if (unity::IsRunning()) 389 if (unity::IsRunning())
380 unity::SetProgressFraction(percentage); 390 unity::SetProgressFraction(percentage);
381 } 391 }
382 392
393 bool Gtk2UI::IsStatusIconSupported() const {
394 return AppIndicatorIcon::CouldOpen();
395 }
396
397 StatusIconLinux* Gtk2UI::CreateLinuxStatusIcon() const {
398 if (AppIndicatorIcon::CouldOpen()) {
399 ++indicators_count;
400 return new AppIndicatorIcon(
401 base::StringPrintf("%s%d", kAppIndicatorIdPrefix, indicators_count));
402 } else {
403 return NULL;
404 }
405 }
406
383 ui::SelectFileDialog* Gtk2UI::CreateSelectFileDialog( 407 ui::SelectFileDialog* Gtk2UI::CreateSelectFileDialog(
384 ui::SelectFileDialog::Listener* listener, 408 ui::SelectFileDialog::Listener* listener,
385 ui::SelectFilePolicy* policy) const { 409 ui::SelectFilePolicy* policy) const {
386 return SelectFileDialogImpl::Create(listener, policy); 410 return SelectFileDialogImpl::Create(listener, policy);
387 } 411 }
388 412
389 void Gtk2UI::GetScrollbarColors(GdkColor* thumb_active_color, 413 void Gtk2UI::GetScrollbarColors(GdkColor* thumb_active_color,
390 GdkColor* thumb_inactive_color, 414 GdkColor* thumb_inactive_color,
391 GdkColor* track_color) { 415 GdkColor* track_color) {
392 const GdkColor* theme_thumb_active = NULL; 416 const GdkColor* theme_thumb_active = NULL;
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 1038
1015 void Gtk2UI::ClearAllThemeData() { 1039 void Gtk2UI::ClearAllThemeData() {
1016 gtk_images_.clear(); 1040 gtk_images_.clear();
1017 } 1041 }
1018 1042
1019 } // namespace libgtk2ui 1043 } // namespace libgtk2ui
1020 1044
1021 ui::LinuxUI* BuildGtk2UI() { 1045 ui::LinuxUI* BuildGtk2UI() {
1022 return new libgtk2ui::Gtk2UI; 1046 return new libgtk2ui::Gtk2UI;
1023 } 1047 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698