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

Side by Side Diff: chrome/browser/ui/gtk/global_bookmark_menu.cc

Issue 6982010: GTK: Hardy build fix for r84860. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/global_bookmark_menu.h" 5 #include "chrome/browser/ui/gtk/global_bookmark_menu.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 53 }
54 54
55 void GlobalBookmarkMenu::RebuildMenuInFuture() { 55 void GlobalBookmarkMenu::RebuildMenuInFuture() {
56 method_factory_.RevokeAll(); 56 method_factory_.RevokeAll();
57 MessageLoop::current()->PostTask( 57 MessageLoop::current()->PostTask(
58 FROM_HERE, 58 FROM_HERE,
59 method_factory_.NewRunnableMethod(&GlobalBookmarkMenu::RebuildMenu)); 59 method_factory_.NewRunnableMethod(&GlobalBookmarkMenu::RebuildMenu));
60 } 60 }
61 61
62 void GlobalBookmarkMenu::RebuildMenu() { 62 void GlobalBookmarkMenu::RebuildMenu() {
63 #if !GTK_CHECK_VERSION(2, 16, 1)
64 // We can't deal with this case; we need to use dynamic APIs. Thankfully,
65 // this will never visibly do anything on earlier versions of GTK+.
66 return;
67 #endif
63 BookmarkModel* model = profile_->GetBookmarkModel(); 68 BookmarkModel* model = profile_->GetBookmarkModel();
64 DCHECK(model); 69 DCHECK(model);
65 DCHECK(model->IsLoaded()); 70 DCHECK(model->IsLoaded());
66 71
67 ClearBookmarkMenu(); 72 ClearBookmarkMenu();
68 73
69 const BookmarkNode* bar_node = model->GetBookmarkBarNode(); 74 const BookmarkNode* bar_node = model->GetBookmarkBarNode();
70 if (bar_node->child_count()) { 75 if (bar_node->child_count()) {
71 AddBookmarkMenuItem(bookmark_menu_, gtk_separator_menu_item_new()); 76 AddBookmarkMenuItem(bookmark_menu_, gtk_separator_menu_item_new());
72 AddNodeToMenu(bar_node, bookmark_menu_); 77 AddNodeToMenu(bar_node, bookmark_menu_);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 G_CALLBACK(OnBookmarkItemActivatedThunk), this); 130 G_CALLBACK(OnBookmarkItemActivatedThunk), this);
126 } 131 }
127 132
128 AddBookmarkMenuItem(menu, item); 133 AddBookmarkMenuItem(menu, item);
129 } 134 }
130 } 135 }
131 } 136 }
132 137
133 void GlobalBookmarkMenu::ConfigureMenuItem(const BookmarkNode* node, 138 void GlobalBookmarkMenu::ConfigureMenuItem(const BookmarkNode* node,
134 GtkWidget* menu_item) { 139 GtkWidget* menu_item) {
140 // This check is only to make things compile on Hardy; this code won't
141 // display any visible widgets in older systems that don't have a global menu
142 // bar.
143 #if GTK_CHECK_VERSION(2, 16, 1)
135 string16 elided_name = l10n_util::TruncateString(node->GetTitle(), kMaxChars); 144 string16 elided_name = l10n_util::TruncateString(node->GetTitle(), kMaxChars);
136 gtk_menu_item_set_label(GTK_MENU_ITEM(menu_item), 145 gtk_menu_item_set_label(GTK_MENU_ITEM(menu_item),
137 UTF16ToUTF8(elided_name).c_str()); 146 UTF16ToUTF8(elided_name).c_str());
147 #endif
138 148
139 if (node->is_url()) { 149 if (node->is_url()) {
140 std::string tooltip = gtk_util::BuildTooltipTitleFor(node->GetTitle(), 150 std::string tooltip = gtk_util::BuildTooltipTitleFor(node->GetTitle(),
141 node->GetURL()); 151 node->GetURL());
142 gtk_widget_set_tooltip_markup(menu_item, tooltip.c_str()); 152 gtk_widget_set_tooltip_markup(menu_item, tooltip.c_str());
143 } 153 }
144 154
145 const SkBitmap& bitmap = profile_->GetBookmarkModel()->GetFavicon(node); 155 const SkBitmap& bitmap = profile_->GetBookmarkModel()->GetFavicon(node);
146 if (!bitmap.isNull()) { 156 if (!bitmap.isNull()) {
147 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&bitmap); 157 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&bitmap);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 void GlobalBookmarkMenu::OnBookmarkItemActivated(GtkWidget* menu_item) { 261 void GlobalBookmarkMenu::OnBookmarkItemActivated(GtkWidget* menu_item) {
252 // The actual mouse event that generated this activated event was in a 262 // The actual mouse event that generated this activated event was in a
253 // different process. Go with something default. 263 // different process. Go with something default.
254 const BookmarkNode* node = static_cast<const BookmarkNode*>( 264 const BookmarkNode* node = static_cast<const BookmarkNode*>(
255 g_object_get_data(G_OBJECT(menu_item), "bookmark-node")); 265 g_object_get_data(G_OBJECT(menu_item), "bookmark-node"));
256 266
257 browser_->OpenURL(node->GetURL(), GURL(), NEW_FOREGROUND_TAB, 267 browser_->OpenURL(node->GetURL(), GURL(), NEW_FOREGROUND_TAB,
258 PageTransition::AUTO_BOOKMARK); 268 PageTransition::AUTO_BOOKMARK);
259 } 269 }
260 270
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698