diff options
Diffstat (limited to 'chrome/browser/gtk/bookmark_bar_gtk.cc')
-rw-r--r-- | chrome/browser/gtk/bookmark_bar_gtk.cc | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc index cfadd13..dc86bab 100644 --- a/chrome/browser/gtk/bookmark_bar_gtk.cc +++ b/chrome/browser/gtk/bookmark_bar_gtk.cc @@ -279,7 +279,7 @@ void BookmarkBarGtk::Loaded(BookmarkModel* model) { return; RemoveAllBookmarkButtons(); - BookmarkNode* node = model_->GetBookmarkBarNode(); + const BookmarkNode* node = model_->GetBookmarkBarNode(); DCHECK(node && model_->other_node()); CreateAllBookmarkButtons(node); @@ -297,16 +297,16 @@ void BookmarkBarGtk::BookmarkModelBeingDeleted(BookmarkModel* model) { } void BookmarkBarGtk::BookmarkNodeMoved(BookmarkModel* model, - BookmarkNode* old_parent, + const BookmarkNode* old_parent, int old_index, - BookmarkNode* new_parent, + const BookmarkNode* new_parent, int new_index) { BookmarkNodeRemoved(model, old_parent, old_index); BookmarkNodeAdded(model, new_parent, new_index); } void BookmarkBarGtk::BookmarkNodeAdded(BookmarkModel* model, - BookmarkNode* parent, + const BookmarkNode* parent, int index) { if (parent != model_->GetBookmarkBarNode()) { // We only care about nodes on the bookmark bar. @@ -322,7 +322,7 @@ void BookmarkBarGtk::BookmarkNodeAdded(BookmarkModel* model, } void BookmarkBarGtk::BookmarkNodeRemoved(BookmarkModel* model, - BookmarkNode* parent, + const BookmarkNode* parent, int index) { if (parent != model_->GetBookmarkBarNode()) { // We only care about nodes on the bookmark bar. @@ -339,7 +339,7 @@ void BookmarkBarGtk::BookmarkNodeRemoved(BookmarkModel* model, } void BookmarkBarGtk::BookmarkNodeChanged(BookmarkModel* model, - BookmarkNode* node) { + const BookmarkNode* node) { if (node->GetParent() != model_->GetBookmarkBarNode()) { // We only care about nodes on the bookmark bar. return; @@ -354,12 +354,12 @@ void BookmarkBarGtk::BookmarkNodeChanged(BookmarkModel* model, } void BookmarkBarGtk::BookmarkNodeFavIconLoaded(BookmarkModel* model, - BookmarkNode* node) { + const BookmarkNode* node) { BookmarkNodeChanged(model, node); } void BookmarkBarGtk::BookmarkNodeChildrenReordered(BookmarkModel* model, - BookmarkNode* node) { + const BookmarkNode* node) { if (node != model_->GetBookmarkBarNode()) return; // We only care about reordering of the bookmark bar node. @@ -368,7 +368,7 @@ void BookmarkBarGtk::BookmarkNodeChildrenReordered(BookmarkModel* model, CreateAllBookmarkButtons(node); } -void BookmarkBarGtk::CreateAllBookmarkButtons(BookmarkNode* node) { +void BookmarkBarGtk::CreateAllBookmarkButtons(const BookmarkNode* node) { // Create a button for each of the children on the bookmark bar. for (int i = 0; i < node->GetChildCount(); ++i) { GtkToolItem* item = CreateBookmarkToolItem(node->GetChild(i)); @@ -378,7 +378,8 @@ void BookmarkBarGtk::CreateAllBookmarkButtons(BookmarkNode* node) { SetInstructionState(node); } -void BookmarkBarGtk::SetInstructionState(BookmarkNode* boomarks_bar_node) { +void BookmarkBarGtk::SetInstructionState( + const BookmarkNode* boomarks_bar_node) { show_instructions_ = (boomarks_bar_node->GetChildCount() == 0); if (show_instructions_) { gtk_widget_show_all(instructions_); @@ -418,7 +419,7 @@ void BookmarkBarGtk::AnimationEnded(const Animation* animation) { gtk_widget_hide(bookmark_hbox_.get()); } -void BookmarkBarGtk::ConfigureButtonForNode(BookmarkNode* node, +void BookmarkBarGtk::ConfigureButtonForNode(const BookmarkNode* node, GtkWidget* button) { std::string tooltip = BuildTooltip(node); if (!tooltip.empty()) @@ -439,10 +440,10 @@ void BookmarkBarGtk::ConfigureButtonForNode(BookmarkNode* node, SetButtonTextColors(button); g_object_set_data(G_OBJECT(button), kBookmarkNode, - reinterpret_cast<void*>(node)); + reinterpret_cast<void*>(const_cast<BookmarkNode*>(node))); } -GtkWidget* BookmarkBarGtk::CreateBookmarkButton(BookmarkNode* node) { +GtkWidget* BookmarkBarGtk::CreateBookmarkButton(const BookmarkNode* node) { GtkWidget* button = gtk_chrome_button_new(); ConfigureButtonForNode(node, button); @@ -477,7 +478,7 @@ GtkWidget* BookmarkBarGtk::CreateBookmarkButton(BookmarkNode* node) { return button; } -GtkToolItem* BookmarkBarGtk::CreateBookmarkToolItem(BookmarkNode* node) { +GtkToolItem* BookmarkBarGtk::CreateBookmarkToolItem(const BookmarkNode* node) { GtkWidget* button = CreateBookmarkButton(node); g_object_set_data(G_OBJECT(button), "left-align-popup", reinterpret_cast<void*>(true)); @@ -499,13 +500,13 @@ void BookmarkBarGtk::ConnectFolderButtonEvents(GtkWidget* widget) { G_CALLBACK(OnFolderButtonReleased), this); } -std::string BookmarkBarGtk::BuildTooltip(BookmarkNode* node) { +std::string BookmarkBarGtk::BuildTooltip(const BookmarkNode* node) { // TODO(erg): Actually build the tooltip. For now, we punt and just return // the URL. return node->GetURL().possibly_invalid_spec(); } -BookmarkNode* BookmarkBarGtk::GetNodeForToolButton(GtkWidget* widget) { +const BookmarkNode* BookmarkBarGtk::GetNodeForToolButton(GtkWidget* widget) { // First check to see if |button| is special cased. if (widget == other_bookmarks_button_) return model_->other_node(); @@ -542,15 +543,16 @@ void BookmarkBarGtk::InitBackground() { 0, IDR_THEME_TOOLBAR, 0, 0, 0, 0, 0, 0, 0)); } -void BookmarkBarGtk::PopupMenuForNode(GtkWidget* sender, BookmarkNode* node, +void BookmarkBarGtk::PopupMenuForNode(GtkWidget* sender, + const BookmarkNode* node, GdkEventButton* event) { if (!model_->IsLoaded()) { // Don't do anything if the model isn't loaded. return; } - BookmarkNode* parent = NULL; - std::vector<BookmarkNode*> nodes; + const BookmarkNode* parent = NULL; + std::vector<const BookmarkNode*> nodes; if (sender == other_bookmarks_button_) { parent = model_->GetBookmarkBarNode(); nodes.push_back(parent); @@ -578,7 +580,7 @@ gboolean BookmarkBarGtk::OnButtonPressed(GtkWidget* sender, bar->ignore_button_release_ = false; if (event->button == 3) { - BookmarkNode* node = bar->GetNodeForToolButton(sender); + const BookmarkNode* node = bar->GetNodeForToolButton(sender); DCHECK(node); DCHECK(bar->page_navigator_); bar->PopupMenuForNode(sender, node, event); @@ -597,7 +599,7 @@ gboolean BookmarkBarGtk::OnButtonReleased(GtkWidget* sender, return FALSE; } - BookmarkNode* node = bar->GetNodeForToolButton(sender); + const BookmarkNode* node = bar->GetNodeForToolButton(sender); DCHECK(node); DCHECK(bar->page_navigator_); @@ -630,7 +632,7 @@ void BookmarkBarGtk::OnButtonDragBegin(GtkWidget* button, // pressing. bar->ignore_button_release_ = true; - BookmarkNode* node = bar->GetNodeForToolButton(button); + const BookmarkNode* node = bar->GetNodeForToolButton(button); DCHECK(!bar->dragged_node_); bar->dragged_node_ = node; DCHECK(bar->dragged_node_); @@ -680,8 +682,8 @@ void BookmarkBarGtk::OnButtonDragGet(GtkWidget* widget, GdkDragContext* context, GtkSelectionData* selection_data, guint target_type, guint time, BookmarkBarGtk* bar) { - BookmarkNode* node = - reinterpret_cast<BookmarkNode*>( + const BookmarkNode* node = + reinterpret_cast<const BookmarkNode*>( g_object_get_data(G_OBJECT(widget), kBookmarkNode)); bookmark_utils::WriteBookmarkToSelection(node, selection_data, target_type, bar->profile_); @@ -697,7 +699,7 @@ gboolean BookmarkBarGtk::OnFolderButtonReleased(GtkWidget* sender, return FALSE; } - BookmarkNode* node = bar->GetNodeForToolButton(sender); + const BookmarkNode* node = bar->GetNodeForToolButton(sender); DCHECK(node); DCHECK(bar->page_navigator_); @@ -807,7 +809,7 @@ void BookmarkBarGtk::OnToolbarDragReceived(GtkWidget* widget, gboolean dnd_success = FALSE; gboolean delete_selection_data = FALSE; - std::vector<BookmarkNode*> nodes = + std::vector<const BookmarkNode*> nodes = bookmark_utils::GetNodesFromSelection(context, selection_data, target_type, bar->profile_, @@ -816,7 +818,7 @@ void BookmarkBarGtk::OnToolbarDragReceived(GtkWidget* widget, DCHECK(!nodes.empty()); gint index = gtk_toolbar_get_drop_index( GTK_TOOLBAR(bar->bookmark_toolbar_.get()), x, y); - for (std::vector<BookmarkNode*>::iterator it = nodes.begin(); + for (std::vector<const BookmarkNode*>::iterator it = nodes.begin(); it != nodes.end(); ++it) { bar->model_->Move(*it, bar->model_->GetBookmarkBarNode(), index); index = bar->model_->GetBookmarkBarNode()->IndexOfChild(*it) + 1; |