| 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 "chrome/browser/gtk/bookmark_menu_controller_gtk.h" | 5 #include "chrome/browser/gtk/bookmark_menu_controller_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "app/gtk_dnd_util.h" | 9 #include "app/gtk_dnd_util.h" |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| 11 #include "app/resource_bundle.h" | 11 #include "app/resource_bundle.h" |
| 12 #include "base/gfx/gtk_util.h" | 12 #include "base/gfx/gtk_util.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "chrome/browser/bookmarks/bookmark_model.h" | 14 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 15 #include "chrome/browser/gtk/bookmark_context_menu.h" | 15 #include "chrome/browser/gtk/bookmark_context_menu_gtk.h" |
| 16 #include "chrome/browser/gtk/bookmark_utils_gtk.h" | 16 #include "chrome/browser/gtk/bookmark_utils_gtk.h" |
| 17 #include "chrome/browser/gtk/gtk_chrome_button.h" | 17 #include "chrome/browser/gtk/gtk_chrome_button.h" |
| 18 #include "chrome/browser/gtk/gtk_theme_provider.h" | 18 #include "chrome/browser/gtk/gtk_theme_provider.h" |
| 19 #include "chrome/browser/gtk/menu_gtk.h" | 19 #include "chrome/browser/gtk/menu_gtk.h" |
| 20 #include "chrome/browser/profile.h" | 20 #include "chrome/browser/profile.h" |
| 21 #include "chrome/browser/tab_contents/page_navigator.h" | 21 #include "chrome/browser/tab_contents/page_navigator.h" |
| 22 #include "chrome/common/gtk_util.h" | 22 #include "chrome/common/gtk_util.h" |
| 23 #include "grit/app_resources.h" | 23 #include "grit/app_resources.h" |
| 24 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
| 25 #include "grit/theme_resources.h" | 25 #include "grit/theme_resources.h" |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 menu_item ? GetNodeFromMenuItem(menu_item) : NULL; | 243 menu_item ? GetNodeFromMenuItem(menu_item) : NULL; |
| 244 DCHECK_NE(is_empty_menu, !!node); | 244 DCHECK_NE(is_empty_menu, !!node); |
| 245 if (!is_empty_menu) | 245 if (!is_empty_menu) |
| 246 parent = node->GetParent(); | 246 parent = node->GetParent(); |
| 247 | 247 |
| 248 // Show the right click menu and stop processing this button event. | 248 // Show the right click menu and stop processing this button event. |
| 249 std::vector<const BookmarkNode*> nodes; | 249 std::vector<const BookmarkNode*> nodes; |
| 250 if (node) | 250 if (node) |
| 251 nodes.push_back(node); | 251 nodes.push_back(node); |
| 252 controller->context_menu_.reset( | 252 controller->context_menu_.reset( |
| 253 new BookmarkContextMenu( | 253 new BookmarkContextMenuGtk( |
| 254 GTK_WIDGET(controller->parent_window_), controller->profile_, | 254 GTK_WIDGET(controller->parent_window_), controller->profile_, |
| 255 controller->browser_, controller->page_navigator_, parent, nodes, | 255 controller->browser_, controller->page_navigator_, parent, nodes, |
| 256 BookmarkContextMenu::BOOKMARK_BAR, controller)); | 256 BookmarkContextMenuGtk::BOOKMARK_BAR, controller)); |
| 257 | 257 |
| 258 // Our bookmark folder menu loses the grab to the context menu. When the | 258 // Our bookmark folder menu loses the grab to the context menu. When the |
| 259 // context menu is hidden, re-assert our grab. | 259 // context menu is hidden, re-assert our grab. |
| 260 GtkWidget* grabbing_menu = gtk_grab_get_current(); | 260 GtkWidget* grabbing_menu = gtk_grab_get_current(); |
| 261 g_object_ref(grabbing_menu); | 261 g_object_ref(grabbing_menu); |
| 262 g_signal_connect(controller->context_menu_->menu(), "hide", | 262 g_signal_connect(controller->context_menu_->menu(), "hide", |
| 263 G_CALLBACK(OnContextMenuHide), grabbing_menu); | 263 G_CALLBACK(OnContextMenuHide), grabbing_menu); |
| 264 | 264 |
| 265 controller->context_menu_->PopupAsContext(event->time); | 265 controller->context_menu_->PopupAsContext(event->time); |
| 266 return TRUE; | 266 return TRUE; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 // static | 347 // static |
| 348 void BookmarkMenuController::OnMenuItemDragGet( | 348 void BookmarkMenuController::OnMenuItemDragGet( |
| 349 GtkWidget* widget, GdkDragContext* context, | 349 GtkWidget* widget, GdkDragContext* context, |
| 350 GtkSelectionData* selection_data, | 350 GtkSelectionData* selection_data, |
| 351 guint target_type, guint time, | 351 guint target_type, guint time, |
| 352 BookmarkMenuController* controller) { | 352 BookmarkMenuController* controller) { |
| 353 const BookmarkNode* node = bookmark_utils::BookmarkNodeForWidget(widget); | 353 const BookmarkNode* node = bookmark_utils::BookmarkNodeForWidget(widget); |
| 354 bookmark_utils::WriteBookmarkToSelection(node, selection_data, target_type, | 354 bookmark_utils::WriteBookmarkToSelection(node, selection_data, target_type, |
| 355 controller->profile_); | 355 controller->profile_); |
| 356 } | 356 } |
| OLD | NEW |