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/gtk/gtk_theme_service.h" | 5 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
13 #include "base/environment.h" | 13 #include "base/environment.h" |
| 14 #include "base/nix/mime_util_xdg.h" |
14 #include "base/nix/xdg_util.h" | 15 #include "base/nix/xdg_util.h" |
15 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
16 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/themes/theme_service_factory.h" | 19 #include "chrome/browser/themes/theme_service_factory.h" |
19 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
20 #include "chrome/browser/ui/browser_iterator.h" | 21 #include "chrome/browser/ui/browser_iterator.h" |
21 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
22 #include "chrome/browser/ui/gtk/chrome_gtk_frame.h" | 23 #include "chrome/browser/ui/gtk/chrome_gtk_frame.h" |
23 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" | 24 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 } | 622 } |
622 | 623 |
623 void GtkThemeService::LoadThemePrefs() { | 624 void GtkThemeService::LoadThemePrefs() { |
624 if (use_gtk_) { | 625 if (use_gtk_) { |
625 LoadGtkValues(); | 626 LoadGtkValues(); |
626 } else { | 627 } else { |
627 LoadDefaultValues(); | 628 LoadDefaultValues(); |
628 ThemeService::LoadThemePrefs(); | 629 ThemeService::LoadThemePrefs(); |
629 } | 630 } |
630 | 631 |
| 632 SetXDGIconTheme(); |
631 RebuildMenuIconSets(); | 633 RebuildMenuIconSets(); |
632 } | 634 } |
633 | 635 |
634 void GtkThemeService::NotifyThemeChanged() { | 636 void GtkThemeService::NotifyThemeChanged() { |
635 ThemeService::NotifyThemeChanged(); | 637 ThemeService::NotifyThemeChanged(); |
636 | 638 |
637 // Notify all GtkChromeButtons of their new rendering mode: | 639 // Notify all GtkChromeButtons of their new rendering mode: |
638 for (std::vector<GtkWidget*>::iterator it = chrome_buttons_.begin(); | 640 for (std::vector<GtkWidget*>::iterator it = chrome_buttons_.begin(); |
639 it != chrome_buttons_.end(); ++it) { | 641 it != chrome_buttons_.end(); ++it) { |
640 gtk_chrome_button_set_use_gtk_rendering( | 642 gtk_chrome_button_set_use_gtk_rendering( |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 | 677 |
676 if (profile()->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme)) { | 678 if (profile()->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme)) { |
677 ClearAllThemeData(); | 679 ClearAllThemeData(); |
678 LoadGtkValues(); | 680 LoadGtkValues(); |
679 NotifyThemeChanged(); | 681 NotifyThemeChanged(); |
680 } | 682 } |
681 | 683 |
682 RebuildMenuIconSets(); | 684 RebuildMenuIconSets(); |
683 } | 685 } |
684 | 686 |
| 687 void GtkThemeService::SetXDGIconTheme() { |
| 688 gchar* gtk_theme_name; |
| 689 g_object_get(gtk_settings_get_default(), |
| 690 "gtk-icon-theme-name", |
| 691 >k_theme_name, NULL); |
| 692 base::nix::SetIconThemeName(gtk_theme_name); |
| 693 g_free(gtk_theme_name); |
| 694 } |
| 695 |
685 void GtkThemeService::LoadGtkValues() { | 696 void GtkThemeService::LoadGtkValues() { |
686 // Before we start setting images and values, we have to clear out old, stale | 697 // Before we start setting images and values, we have to clear out old, stale |
687 // values. (If we don't do this, we'll regress startup time in the case where | 698 // values. (If we don't do this, we'll regress startup time in the case where |
688 // someone installs a heavyweight theme, then goes back to GTK.) | 699 // someone installs a heavyweight theme, then goes back to GTK.) |
689 profile()->GetPrefs()->ClearPref(prefs::kCurrentThemeImages); | 700 profile()->GetPrefs()->ClearPref(prefs::kCurrentThemeImages); |
690 | 701 |
691 GtkStyle* frame_style = gtk_rc_get_style(fake_frame_); | 702 GtkStyle* frame_style = gtk_rc_get_style(fake_frame_); |
692 | 703 |
693 GtkStyle* window_style = gtk_rc_get_style(fake_window_); | 704 GtkStyle* window_style = gtk_rc_get_style(fake_window_); |
694 SetThemeColorFromGtk(ThemeService::COLOR_CONTROL_BACKGROUND, | 705 SetThemeColorFromGtk(ThemeService::COLOR_CONTROL_BACKGROUND, |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 cairo_stroke(cr); | 1154 cairo_stroke(cr); |
1144 cairo_destroy(cr); | 1155 cairo_destroy(cr); |
1145 cairo_pattern_destroy(pattern); | 1156 cairo_pattern_destroy(pattern); |
1146 | 1157 |
1147 return TRUE; | 1158 return TRUE; |
1148 } | 1159 } |
1149 | 1160 |
1150 void GtkThemeService::OnUsesSystemThemeChanged() { | 1161 void GtkThemeService::OnUsesSystemThemeChanged() { |
1151 use_gtk_ = profile()->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme); | 1162 use_gtk_ = profile()->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme); |
1152 } | 1163 } |
OLD | NEW |