OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/mime_util.h" | 5 #include "base/mime_util.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 #include <sys/time.h> | 8 #include <sys/time.h> |
9 #include <time.h> | 9 #include <time.h> |
10 | 10 |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 // Assume it's Gnome and use GTK to figure out the theme. | 504 // Assume it's Gnome and use GTK to figure out the theme. |
505 gchar* gtk_theme_name; | 505 gchar* gtk_theme_name; |
506 g_object_get(gtk_settings_get_default(), | 506 g_object_get(gtk_settings_get_default(), |
507 "gtk-icon-theme-name", | 507 "gtk-icon-theme-name", |
508 >k_theme_name, NULL); | 508 >k_theme_name, NULL); |
509 default_themes[1] = IconTheme::LoadTheme(gtk_theme_name); | 509 default_themes[1] = IconTheme::LoadTheme(gtk_theme_name); |
510 default_themes[2] = IconTheme::LoadTheme("gnome"); | 510 default_themes[2] = IconTheme::LoadTheme("gnome"); |
511 } | 511 } |
512 // hicolor needs to be last per icon theme spec. | 512 // hicolor needs to be last per icon theme spec. |
513 default_themes[3] = IconTheme::LoadTheme("hicolor"); | 513 default_themes[3] = IconTheme::LoadTheme("hicolor"); |
| 514 |
| 515 for (size_t i = 0; i < MimeUtilConstants::kDefaultThemeNum; i++) { |
| 516 if (default_themes[i] == NULL) |
| 517 continue; |
| 518 // NULL out duplicate pointers. |
| 519 for (size_t j = i + 1; j < MimeUtilConstants::kDefaultThemeNum; j++) { |
| 520 if (default_themes[j] == default_themes[i]) |
| 521 default_themes[j] = NULL; |
| 522 } |
| 523 } |
514 } | 524 } |
515 | 525 |
516 // Try to find an icon with the name |icon_name| that's |size| pixels. | 526 // Try to find an icon with the name |icon_name| that's |size| pixels. |
517 FilePath LookupIconInDefaultTheme(const std::string& icon_name, int size) { | 527 FilePath LookupIconInDefaultTheme(const std::string& icon_name, int size) { |
518 EnsureUpdated(); | 528 EnsureUpdated(); |
519 MimeUtilConstants* constants = Singleton<MimeUtilConstants>::get(); | 529 MimeUtilConstants* constants = Singleton<MimeUtilConstants>::get(); |
520 std::map<std::string, IconTheme*>* icon_themes = constants->icon_themes; | 530 std::map<std::string, IconTheme*>* icon_themes = constants->icon_themes; |
521 if (icon_themes->size() == 0) | 531 if (icon_themes->size() == 0) |
522 InitDefaultThemes(); | 532 InitDefaultThemes(); |
523 | 533 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 } else { | 598 } else { |
589 icon_file = LookupIconInDefaultTheme(icon_names[i], size); | 599 icon_file = LookupIconInDefaultTheme(icon_names[i], size); |
590 if (!icon_file.empty()) | 600 if (!icon_file.empty()) |
591 return icon_file; | 601 return icon_file; |
592 } | 602 } |
593 } | 603 } |
594 return FilePath(); | 604 return FilePath(); |
595 } | 605 } |
596 | 606 |
597 } // namespace mime_util | 607 } // namespace mime_util |
OLD | NEW |