OLD | NEW |
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/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/nix/mime_util_xdg.h" |
12 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
13 #include "chrome/browser/themes/theme_service.h" | 14 #include "chrome/browser/themes/theme_service.h" |
14 #include "chrome/browser/ui/libgtk2ui/chrome_gtk_frame.h" | 15 #include "chrome/browser/ui/libgtk2ui/chrome_gtk_frame.h" |
15 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" | 16 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" |
16 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h" | 17 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h" |
17 #include "chrome/browser/ui/libgtk2ui/skia_utils_gtk2.h" | 18 #include "chrome/browser/ui/libgtk2ui/skia_utils_gtk2.h" |
18 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
19 #include "grit/ui_resources.h" | 20 #include "grit/ui_resources.h" |
20 #include "third_party/skia/include/core/SkBitmap.h" | 21 #include "third_party/skia/include/core/SkBitmap.h" |
21 #include "third_party/skia/include/core/SkCanvas.h" | 22 #include "third_party/skia/include/core/SkCanvas.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 // Only realized widgets receive style-set notifications, which we need to | 285 // Only realized widgets receive style-set notifications, which we need to |
285 // broadcast new theme images and colors. Only realized widgets have style | 286 // broadcast new theme images and colors. Only realized widgets have style |
286 // properties, too, which we query for some colors. | 287 // properties, too, which we query for some colors. |
287 gtk_widget_realize(fake_frame_); | 288 gtk_widget_realize(fake_frame_); |
288 gtk_widget_realize(fake_window_); | 289 gtk_widget_realize(fake_window_); |
289 // TODO: Also listen for "style-set" on the fake frame. | 290 // TODO: Also listen for "style-set" on the fake frame. |
290 | 291 |
291 // TODO(erg): Be lazy about generating this data and connect it to the | 292 // TODO(erg): Be lazy about generating this data and connect it to the |
292 // style-set signal handler. | 293 // style-set signal handler. |
293 LoadGtkValues(); | 294 LoadGtkValues(); |
| 295 SetXDGIconTheme(); |
294 } | 296 } |
295 | 297 |
296 Gtk2UI::~Gtk2UI() { | 298 Gtk2UI::~Gtk2UI() { |
297 gtk_widget_destroy(fake_window_); | 299 gtk_widget_destroy(fake_window_); |
298 gtk_widget_destroy(fake_frame_); | 300 gtk_widget_destroy(fake_frame_); |
299 fake_label_.Destroy(); | 301 fake_label_.Destroy(); |
300 fake_entry_.Destroy(); | 302 fake_entry_.Destroy(); |
301 | 303 |
302 ClearAllThemeData(); | 304 ClearAllThemeData(); |
303 } | 305 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 if (theme_thumb_active) | 433 if (theme_thumb_active) |
432 *thumb_active_color = *theme_thumb_active; | 434 *thumb_active_color = *theme_thumb_active; |
433 | 435 |
434 if (theme_thumb_inactive) | 436 if (theme_thumb_inactive) |
435 *thumb_inactive_color = *theme_thumb_inactive; | 437 *thumb_inactive_color = *theme_thumb_inactive; |
436 | 438 |
437 if (theme_trough_color) | 439 if (theme_trough_color) |
438 *track_color = *theme_trough_color; | 440 *track_color = *theme_trough_color; |
439 } | 441 } |
440 | 442 |
| 443 void Gtk2UI::SetXDGIconTheme() { |
| 444 gchar* gtk_theme_name; |
| 445 g_object_get(gtk_settings_get_default(), |
| 446 "gtk-icon-theme-name", |
| 447 >k_theme_name, NULL); |
| 448 base::nix::SetIconThemeName(gtk_theme_name); |
| 449 g_free(gtk_theme_name); |
| 450 } |
| 451 |
441 void Gtk2UI::LoadGtkValues() { | 452 void Gtk2UI::LoadGtkValues() { |
442 // TODO(erg): GtkThemeService had a comment here about having to muck with | 453 // TODO(erg): GtkThemeService had a comment here about having to muck with |
443 // the raw Prefs object to remove prefs::kCurrentThemeImages or else we'd | 454 // the raw Prefs object to remove prefs::kCurrentThemeImages or else we'd |
444 // regress startup time. Figure out how to do that when we can't access the | 455 // regress startup time. Figure out how to do that when we can't access the |
445 // prefs system from here. | 456 // prefs system from here. |
446 | 457 |
447 GtkStyle* frame_style = gtk_rc_get_style(fake_frame_); | 458 GtkStyle* frame_style = gtk_rc_get_style(fake_frame_); |
448 | 459 |
449 GtkStyle* window_style = gtk_rc_get_style(fake_window_); | 460 GtkStyle* window_style = gtk_rc_get_style(fake_window_); |
450 SetThemeColorFromGtk(ThemeService::COLOR_CONTROL_BACKGROUND, | 461 SetThemeColorFromGtk(ThemeService::COLOR_CONTROL_BACKGROUND, |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 | 969 |
959 void Gtk2UI::ClearAllThemeData() { | 970 void Gtk2UI::ClearAllThemeData() { |
960 STLDeleteValues(>k_images_); | 971 STLDeleteValues(>k_images_); |
961 } | 972 } |
962 | 973 |
963 } // namespace libgtk2ui | 974 } // namespace libgtk2ui |
964 | 975 |
965 ui::LinuxUI* BuildGtk2UI() { | 976 ui::LinuxUI* BuildGtk2UI() { |
966 return new libgtk2ui::Gtk2UI; | 977 return new libgtk2ui::Gtk2UI; |
967 } | 978 } |
OLD | NEW |