diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-11 22:27:03 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-11 22:27:03 +0000 |
commit | 279e814726e6a3657c3b9e6ce458e13fd895df96 (patch) | |
tree | 972bc1c3d3cdc87ae70cdf0d722bd4dd16d91cf0 /chrome/browser | |
parent | 2b4a20ecd8e1447df2a87b5e9e4cae0b0bd8fb2d (diff) | |
download | chromium_src-279e814726e6a3657c3b9e6ce458e13fd895df96.zip chromium_src-279e814726e6a3657c3b9e6ce458e13fd895df96.tar.gz chromium_src-279e814726e6a3657c3b9e6ce458e13fd895df96.tar.bz2 |
Display folder icons for folder items in the menu and submenus.
BUG=26947
TEST=bookmark menu should behave normally but folders should now have icons too.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35950 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/cocoa/bookmark_menu_bridge.h | 5 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_menu_bridge.mm | 9 |
2 files changed, 14 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/bookmark_menu_bridge.h b/chrome/browser/cocoa/bookmark_menu_bridge.h index 577144e..b28b5b7 100644 --- a/chrome/browser/cocoa/bookmark_menu_bridge.h +++ b/chrome/browser/cocoa/bookmark_menu_bridge.h @@ -21,10 +21,12 @@ #define CHROME_BROWSER_COCOA_BOOKMARK_MENU_BRIDGE_H_ #include <map> +#include "base/scoped_nsobject.h" #include "chrome/browser/bookmarks/bookmark_model_observer.h" class BookmarkNode; class Profile; +@class NSImage; @class NSMenu; @class NSMenuItem; @class BookmarkMenuCocoaController; @@ -99,6 +101,9 @@ class BookmarkMenuBridge : public BookmarkModelObserver { Profile* profile_; // weak BookmarkMenuCocoaController* controller_; // strong + // The folder image so we can use one copy for all. + scoped_nsobject<NSImage> folder_image_; + // In order to appropriately update items in the bookmark menu, without // forcing a rebuild, map the model's nodes to menu items. std::map<const BookmarkNode*, NSMenuItem*> bookmark_nodes_; diff --git a/chrome/browser/cocoa/bookmark_menu_bridge.mm b/chrome/browser/cocoa/bookmark_menu_bridge.mm index 3de295d..c198145 100644 --- a/chrome/browser/cocoa/bookmark_menu_bridge.mm +++ b/chrome/browser/cocoa/bookmark_menu_bridge.mm @@ -5,6 +5,7 @@ #import <AppKit/AppKit.h> #include "app/l10n_util.h" +#include "app/resource_bundle.h" #include "base/nsimage_cache_mac.h" #include "base/sys_string_conversions.h" #include "chrome/app/chrome_dll_resource.h" // IDC_BOOKMARK_MENU @@ -17,6 +18,7 @@ #include "chrome/browser/profile.h" #include "chrome/browser/profile_manager.h" #include "grit/generated_resources.h" +#include "grit/theme_resources.h" #include "skia/ext/skia_utils_mac.h" BookmarkMenuBridge::BookmarkMenuBridge(Profile* profile) @@ -44,6 +46,11 @@ void BookmarkMenuBridge::Loaded(BookmarkModel* model) { if (bookmark_menu == nil) return; + if (!folder_image_) { + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + folder_image_.reset([rb.GetNSImageNamed(IDR_BOOKMARK_BAR_FOLDER) retain]); + } + ClearBookmarkMenu(bookmark_menu); // Add bookmark bar items, if any. @@ -161,6 +168,7 @@ void BookmarkMenuBridge::AddNodeAsSubmenu(NSMenu* menu, initWithTitle:title action:nil keyEquivalent:@""] autorelease]; + [items setImage:folder_image_]; [menu addItem:items]; NSMenu* other_submenu = [[[NSMenu alloc] initWithTitle:title] autorelease]; @@ -179,6 +187,7 @@ void BookmarkMenuBridge::AddNodeToMenu(const BookmarkNode* node, NSMenu* menu) { [menu addItem:item]; bookmark_nodes_[child] = item; if (child->is_folder()) { + [item setImage:folder_image_]; NSMenu* submenu = [[[NSMenu alloc] initWithTitle:title] autorelease]; [menu setSubmenu:submenu forItem:item]; AddNodeToMenu(child, submenu); // recursive call |