| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_UI_GTK_BOOKMARKS_BOOKMARK_BAR_GTK_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_BOOKMARKS_BOOKMARK_BAR_GTK_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_BOOKMARKS_BOOKMARK_BAR_GTK_H_ | 6 #define CHROME_BROWSER_UI_GTK_BOOKMARKS_BOOKMARK_BAR_GTK_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
| 10 | 10 |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "chrome/browser/bookmarks/bookmark_context_menu_controller.h" | 16 #include "chrome/browser/bookmarks/bookmark_context_menu_controller.h" |
| 17 #include "chrome/browser/bookmarks/bookmark_model_observer.h" | 17 #include "chrome/browser/bookmarks/bookmark_model_observer.h" |
| 18 #include "chrome/browser/prefs/pref_member.h" | 18 #include "chrome/browser/prefs/pref_member.h" |
| 19 #include "chrome/browser/sync/profile_sync_service.h" | |
| 20 #include "chrome/browser/ui/bookmarks/bookmark_bar.h" | 19 #include "chrome/browser/ui/bookmarks/bookmark_bar.h" |
| 21 #include "chrome/browser/ui/gtk/bookmarks/bookmark_bar_instructions_gtk.h" | 20 #include "chrome/browser/ui/gtk/bookmarks/bookmark_bar_instructions_gtk.h" |
| 22 #include "chrome/browser/ui/gtk/menu_bar_helper.h" | 21 #include "chrome/browser/ui/gtk/menu_bar_helper.h" |
| 23 #include "chrome/browser/ui/gtk/view_id_util.h" | 22 #include "chrome/browser/ui/gtk/view_id_util.h" |
| 24 #include "content/public/browser/notification_observer.h" | 23 #include "content/public/browser/notification_observer.h" |
| 25 #include "content/public/browser/notification_registrar.h" | 24 #include "content/public/browser/notification_registrar.h" |
| 26 #include "ui/base/animation/animation.h" | 25 #include "ui/base/animation/animation.h" |
| 27 #include "ui/base/animation/animation_delegate.h" | 26 #include "ui/base/animation/animation_delegate.h" |
| 28 #include "ui/base/animation/slide_animation.h" | 27 #include "ui/base/animation/slide_animation.h" |
| 29 #include "ui/base/gtk/gtk_signal.h" | 28 #include "ui/base/gtk/gtk_signal.h" |
| 30 #include "ui/base/gtk/owned_widget_gtk.h" | 29 #include "ui/base/gtk/owned_widget_gtk.h" |
| 31 #include "ui/gfx/point.h" | 30 #include "ui/gfx/point.h" |
| 32 #include "ui/gfx/size.h" | 31 #include "ui/gfx/size.h" |
| 33 | 32 |
| 34 class BookmarkMenuController; | 33 class BookmarkMenuController; |
| 35 class Browser; | 34 class Browser; |
| 36 class BrowserWindowGtk; | 35 class BrowserWindowGtk; |
| 37 class CustomContainerButton; | 36 class CustomContainerButton; |
| 38 class GtkThemeService; | 37 class GtkThemeService; |
| 39 class MenuGtk; | 38 class MenuGtk; |
| 40 class PageNavigator; | 39 class PageNavigator; |
| 41 class TabstripOriginProvider; | 40 class TabstripOriginProvider; |
| 42 | 41 |
| 43 class BookmarkBarGtk : public ui::AnimationDelegate, | 42 class BookmarkBarGtk : public ui::AnimationDelegate, |
| 44 public ProfileSyncServiceObserver, | |
| 45 public BookmarkModelObserver, | 43 public BookmarkModelObserver, |
| 46 public MenuBarHelper::Delegate, | 44 public MenuBarHelper::Delegate, |
| 47 public content::NotificationObserver, | 45 public content::NotificationObserver, |
| 48 public BookmarkBarInstructionsGtk::Delegate, | 46 public BookmarkBarInstructionsGtk::Delegate, |
| 49 public BookmarkContextMenuControllerDelegate { | 47 public BookmarkContextMenuControllerDelegate { |
| 50 public: | 48 public: |
| 51 // The NTP needs to have access to this. | 49 // The NTP needs to have access to this. |
| 52 static const int kBookmarkBarNTPHeight; | 50 static const int kBookmarkBarNTPHeight; |
| 53 | 51 |
| 54 BookmarkBarGtk(BrowserWindowGtk* window, | 52 BookmarkBarGtk(BrowserWindowGtk* window, |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 // Finds the BookmarkNode from the model associated with |button|. | 244 // Finds the BookmarkNode from the model associated with |button|. |
| 247 const BookmarkNode* GetNodeForToolButton(GtkWidget* button); | 245 const BookmarkNode* GetNodeForToolButton(GtkWidget* button); |
| 248 | 246 |
| 249 // Creates and displays a popup menu for BookmarkNode |node|. | 247 // Creates and displays a popup menu for BookmarkNode |node|. |
| 250 void PopupMenuForNode(GtkWidget* sender, const BookmarkNode* node, | 248 void PopupMenuForNode(GtkWidget* sender, const BookmarkNode* node, |
| 251 GdkEventButton* event); | 249 GdkEventButton* event); |
| 252 | 250 |
| 253 // GtkButton callbacks. | 251 // GtkButton callbacks. |
| 254 CHROMEGTK_CALLBACK_1(BookmarkBarGtk, gboolean, OnButtonPressed, | 252 CHROMEGTK_CALLBACK_1(BookmarkBarGtk, gboolean, OnButtonPressed, |
| 255 GdkEventButton*); | 253 GdkEventButton*); |
| 256 CHROMEGTK_CALLBACK_1(BookmarkBarGtk, gboolean, OnSyncErrorButtonPressed, | |
| 257 GdkEventButton*); | |
| 258 CHROMEGTK_CALLBACK_0(BookmarkBarGtk, void, OnClicked); | 254 CHROMEGTK_CALLBACK_0(BookmarkBarGtk, void, OnClicked); |
| 259 CHROMEGTK_CALLBACK_1(BookmarkBarGtk, void, OnButtonDragBegin, | 255 CHROMEGTK_CALLBACK_1(BookmarkBarGtk, void, OnButtonDragBegin, |
| 260 GdkDragContext*); | 256 GdkDragContext*); |
| 261 CHROMEGTK_CALLBACK_1(BookmarkBarGtk, void, OnButtonDragEnd, GdkDragContext*); | 257 CHROMEGTK_CALLBACK_1(BookmarkBarGtk, void, OnButtonDragEnd, GdkDragContext*); |
| 262 CHROMEGTK_CALLBACK_4(BookmarkBarGtk, void, OnButtonDragGet, | 258 CHROMEGTK_CALLBACK_4(BookmarkBarGtk, void, OnButtonDragGet, |
| 263 GdkDragContext*, GtkSelectionData*, guint, guint); | 259 GdkDragContext*, GtkSelectionData*, guint, guint); |
| 264 | 260 |
| 265 // GtkButton callbacks for folder buttons. | 261 // GtkButton callbacks for folder buttons. |
| 266 CHROMEGTK_CALLBACK_0(BookmarkBarGtk, void, OnFolderClicked); | 262 CHROMEGTK_CALLBACK_0(BookmarkBarGtk, void, OnFolderClicked); |
| 267 | 263 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 287 GdkEventExpose*); | 283 GdkEventExpose*); |
| 288 CHROMEGTK_CALLBACK_0(BookmarkBarGtk, void, OnEventBoxDestroy); | 284 CHROMEGTK_CALLBACK_0(BookmarkBarGtk, void, OnEventBoxDestroy); |
| 289 | 285 |
| 290 // Callbacks on our parent widget. | 286 // Callbacks on our parent widget. |
| 291 CHROMEGTK_CALLBACK_1(BookmarkBarGtk, void, OnParentSizeAllocate, | 287 CHROMEGTK_CALLBACK_1(BookmarkBarGtk, void, OnParentSizeAllocate, |
| 292 GtkAllocation*); | 288 GtkAllocation*); |
| 293 | 289 |
| 294 // |throbbing_widget_| callback. | 290 // |throbbing_widget_| callback. |
| 295 CHROMEGTK_CALLBACK_0(BookmarkBarGtk, void, OnThrobbingWidgetDestroy); | 291 CHROMEGTK_CALLBACK_0(BookmarkBarGtk, void, OnThrobbingWidgetDestroy); |
| 296 | 292 |
| 297 // ProfileSyncServiceObserver method. | |
| 298 virtual void OnStateChanged(); | |
| 299 | |
| 300 // Overriden from BookmarkBarInstructionsGtk::Delegate. | 293 // Overriden from BookmarkBarInstructionsGtk::Delegate. |
| 301 virtual void ShowImportDialog(); | 294 virtual void ShowImportDialog(); |
| 302 | 295 |
| 303 // Updates the drag&drop state when |edit_bookmarks_enabled_| changes. | 296 // Updates the drag&drop state when |edit_bookmarks_enabled_| changes. |
| 304 void OnEditBookmarksEnabledChanged(); | 297 void OnEditBookmarksEnabledChanged(); |
| 305 | 298 |
| 306 // Used for opening urls. | 299 // Used for opening urls. |
| 307 PageNavigator* page_navigator_; | 300 PageNavigator* page_navigator_; |
| 308 | 301 |
| 309 Browser* browser_; | 302 Browser* browser_; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 // A separator between the main bookmark bar area and | 340 // A separator between the main bookmark bar area and |
| 348 // |other_bookmarks_button_|. | 341 // |other_bookmarks_button_|. |
| 349 GtkWidget* other_bookmarks_separator_; | 342 GtkWidget* other_bookmarks_separator_; |
| 350 | 343 |
| 351 // The other bookmarks button. | 344 // The other bookmarks button. |
| 352 GtkWidget* other_bookmarks_button_; | 345 GtkWidget* other_bookmarks_button_; |
| 353 | 346 |
| 354 // Padding for the other bookmarks button. | 347 // Padding for the other bookmarks button. |
| 355 GtkWidget* other_padding_; | 348 GtkWidget* other_padding_; |
| 356 | 349 |
| 357 // The sync error button. | |
| 358 GtkWidget* sync_error_button_; | |
| 359 | |
| 360 // A pointer to the ProfileSyncService instance if one exists. | |
| 361 ProfileSyncService* sync_service_; | |
| 362 | |
| 363 // The BookmarkNode from the model being dragged. NULL when we aren't | 350 // The BookmarkNode from the model being dragged. NULL when we aren't |
| 364 // dragging. | 351 // dragging. |
| 365 const BookmarkNode* dragged_node_; | 352 const BookmarkNode* dragged_node_; |
| 366 | 353 |
| 367 // The visual representation that follows the cursor during drags. | 354 // The visual representation that follows the cursor during drags. |
| 368 GtkWidget* drag_icon_; | 355 GtkWidget* drag_icon_; |
| 369 | 356 |
| 370 // We create a GtkToolbarItem from |dragged_node_| ;or display. | 357 // We create a GtkToolbarItem from |dragged_node_| ;or display. |
| 371 GtkToolItem* toolbar_drop_item_; | 358 GtkToolItem* toolbar_drop_item_; |
| 372 | 359 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 | 403 |
| 417 BookmarkBar::State bookmark_bar_state_; | 404 BookmarkBar::State bookmark_bar_state_; |
| 418 | 405 |
| 419 // Maximum height of the bookmark bar. | 406 // Maximum height of the bookmark bar. |
| 420 int max_height_; | 407 int max_height_; |
| 421 | 408 |
| 422 DISALLOW_COPY_AND_ASSIGN(BookmarkBarGtk); | 409 DISALLOW_COPY_AND_ASSIGN(BookmarkBarGtk); |
| 423 }; | 410 }; |
| 424 | 411 |
| 425 #endif // CHROME_BROWSER_UI_GTK_BOOKMARKS_BOOKMARK_BAR_GTK_H_ | 412 #endif // CHROME_BROWSER_UI_GTK_BOOKMARKS_BOOKMARK_BAR_GTK_H_ |
| OLD | NEW |