| 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 #ifndef CHROME_BROWSER_GTK_BOOKMARK_MENU_CONTROLLER_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_BOOKMARK_MENU_CONTROLLER_GTK_H_ |
| 6 #define CHROME_BROWSER_GTK_BOOKMARK_MENU_CONTROLLER_GTK_H_ | 6 #define CHROME_BROWSER_GTK_BOOKMARK_MENU_CONTROLLER_GTK_H_ |
| 7 | 7 |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 | 11 |
| 12 #include "app/gtk_signal.h" |
| 12 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
| 13 #include "chrome/browser/bookmarks/base_bookmark_model_observer.h" | 14 #include "chrome/browser/bookmarks/base_bookmark_model_observer.h" |
| 14 #include "chrome/browser/bookmarks/bookmark_context_menu_controller.h" | 15 #include "chrome/browser/bookmarks/bookmark_context_menu_controller.h" |
| 15 #include "chrome/common/owned_widget_gtk.h" | 16 #include "chrome/common/owned_widget_gtk.h" |
| 16 #include "webkit/glue/window_open_disposition.h" | 17 #include "webkit/glue/window_open_disposition.h" |
| 17 | 18 |
| 18 class Browser; | 19 class Browser; |
| 19 class Profile; | 20 class Profile; |
| 20 class Profiler; | 21 class Profiler; |
| 21 class PageNavigator; | 22 class PageNavigator; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 61 |
| 61 // Calls the page navigator to navigate to the node represented by | 62 // Calls the page navigator to navigate to the node represented by |
| 62 // |menu_item|. | 63 // |menu_item|. |
| 63 void NavigateToMenuItem(GtkWidget* menu_item, | 64 void NavigateToMenuItem(GtkWidget* menu_item, |
| 64 WindowOpenDisposition disposition); | 65 WindowOpenDisposition disposition); |
| 65 | 66 |
| 66 // Button press and release events for a GtkMenu and GtkMenuItem, | 67 // Button press and release events for a GtkMenu and GtkMenuItem, |
| 67 // respectively. We have to override these separate from OnMenuItemActivated | 68 // respectively. We have to override these separate from OnMenuItemActivated |
| 68 // because we need to handle right clicks and opening bookmarks with | 69 // because we need to handle right clicks and opening bookmarks with |
| 69 // different dispositions. | 70 // different dispositions. |
| 70 static gboolean OnButtonPressed(GtkWidget* sender, | 71 CHROMEGTK_CALLBACK_1(BookmarkMenuController, gboolean, OnButtonPressed, |
| 71 GdkEventButton* event, | 72 GdkEventButton*); |
| 72 BookmarkMenuController* controller); | 73 CHROMEGTK_CALLBACK_1(BookmarkMenuController, gboolean, OnButtonReleased, |
| 73 static gboolean OnButtonReleased(GtkWidget* sender, | 74 GdkEventButton*); |
| 74 GdkEventButton* event, | 75 |
| 75 BookmarkMenuController* controller); | |
| 76 // We connect this handler to the button-press-event signal for folder nodes. | 76 // We connect this handler to the button-press-event signal for folder nodes. |
| 77 // It suppresses the normal behavior (popping up the submenu) to allow these | 77 // It suppresses the normal behavior (popping up the submenu) to allow these |
| 78 // nodes to be draggable. The submenu is instead popped up on a | 78 // nodes to be draggable. The submenu is instead popped up on a |
| 79 // button-release-event. | 79 // button-release-event. |
| 80 static gboolean OnFolderButtonPressed(GtkWidget* sender, | 80 CHROMEGTK_CALLBACK_1(BookmarkMenuController, gboolean, OnFolderButtonPressed, |
| 81 GdkEventButton* event, | 81 GdkEventButton*); |
| 82 BookmarkMenuController* controller); | |
| 83 | 82 |
| 84 // We have to stop drawing |triggering_widget_| as active when the menu | 83 // We have to stop drawing |triggering_widget_| as active when the menu |
| 85 // closes. | 84 // closes. |
| 86 static void OnMenuHidden(GtkWidget* menu, BookmarkMenuController* controller); | 85 CHROMEGTK_CALLBACK_0(BookmarkMenuController, void, OnMenuHidden) |
| 87 | 86 |
| 88 // We respond to the activate signal because things other than mouse button | 87 // We respond to the activate signal because things other than mouse button |
| 89 // events can trigger it. | 88 // events can trigger it. |
| 90 static void OnMenuItemActivated(GtkMenuItem* menuitem, | 89 CHROMEGTK_CALLBACK_0(BookmarkMenuController, void, OnMenuItemActivated); |
| 91 BookmarkMenuController* controller); | |
| 92 | 90 |
| 93 // The individual GtkMenuItems in the BookmarkMenu are all drag sources. | 91 // The individual GtkMenuItems in the BookmarkMenu are all drag sources. |
| 94 static void OnMenuItemDragBegin(GtkWidget* menu_item, | 92 CHROMEGTK_CALLBACK_1(BookmarkMenuController, void, OnMenuItemDragBegin, |
| 95 GdkDragContext* drag_context, | 93 GdkDragContext*); |
| 96 BookmarkMenuController* bar); | 94 CHROMEGTK_CALLBACK_1(BookmarkMenuController, void, OnMenuItemDragEnd, |
| 97 static void OnMenuItemDragEnd(GtkWidget* menu_item, | 95 GdkDragContext*); |
| 98 GdkDragContext* drag_context, | 96 CHROMEGTK_CALLBACK_4(BookmarkMenuController, void, OnMenuItemDragGet, |
| 99 BookmarkMenuController* controller); | 97 GdkDragContext*, GtkSelectionData*, guint, guint); |
| 100 static void OnMenuItemDragGet( | |
| 101 GtkWidget* widget, GdkDragContext* context, | |
| 102 GtkSelectionData* selection_data, | |
| 103 guint target_type, guint time, | |
| 104 BookmarkMenuController* controller); | |
| 105 | 98 |
| 106 Browser* browser_; | 99 Browser* browser_; |
| 107 Profile* profile_; | 100 Profile* profile_; |
| 108 PageNavigator* page_navigator_; | 101 PageNavigator* page_navigator_; |
| 109 | 102 |
| 110 // Parent window of this menu. | 103 // Parent window of this menu. |
| 111 GtkWindow* parent_window_; | 104 GtkWindow* parent_window_; |
| 112 | 105 |
| 113 // The bookmark model. | 106 // The bookmark model. |
| 114 BookmarkModel* model_; | 107 BookmarkModel* model_; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 134 std::map<const BookmarkNode*, GtkWidget*> node_to_menu_widget_map_; | 127 std::map<const BookmarkNode*, GtkWidget*> node_to_menu_widget_map_; |
| 135 | 128 |
| 136 // The controller and view for the right click context menu. | 129 // The controller and view for the right click context menu. |
| 137 scoped_ptr<BookmarkContextMenuController> context_menu_controller_; | 130 scoped_ptr<BookmarkContextMenuController> context_menu_controller_; |
| 138 scoped_ptr<MenuGtk> context_menu_; | 131 scoped_ptr<MenuGtk> context_menu_; |
| 139 | 132 |
| 140 DISALLOW_COPY_AND_ASSIGN(BookmarkMenuController); | 133 DISALLOW_COPY_AND_ASSIGN(BookmarkMenuController); |
| 141 }; | 134 }; |
| 142 | 135 |
| 143 #endif // CHROME_BROWSER_GTK_BOOKMARK_MENU_CONTROLLER_GTK_H_ | 136 #endif // CHROME_BROWSER_GTK_BOOKMARK_MENU_CONTROLLER_GTK_H_ |
| OLD | NEW |