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_BAR_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_BOOKMARK_BAR_GTK_H_ |
6 #define CHROME_BROWSER_GTK_BOOKMARK_BAR_GTK_H_ | 6 #define CHROME_BROWSER_GTK_BOOKMARK_BAR_GTK_H_ |
7 | 7 |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "app/slide_animation.h" | 13 #include "app/slide_animation.h" |
14 #include "base/gfx/size.h" | |
14 #include "base/scoped_ptr.h" | 15 #include "base/scoped_ptr.h" |
15 #include "chrome/browser/bookmarks/bookmark_model_observer.h" | 16 #include "chrome/browser/bookmarks/bookmark_model_observer.h" |
16 #include "chrome/browser/gtk/menu_bar_helper.h" | 17 #include "chrome/browser/gtk/menu_bar_helper.h" |
17 #include "chrome/browser/gtk/view_id_util.h" | 18 #include "chrome/browser/gtk/view_id_util.h" |
18 #include "chrome/browser/sync/profile_sync_service.h" | 19 #include "chrome/browser/sync/profile_sync_service.h" |
19 #include "chrome/common/notification_observer.h" | 20 #include "chrome/common/notification_observer.h" |
20 #include "chrome/common/notification_registrar.h" | 21 #include "chrome/common/notification_registrar.h" |
21 #include "chrome/common/owned_widget_gtk.h" | 22 #include "chrome/common/owned_widget_gtk.h" |
22 #include "testing/gtest/include/gtest/gtest_prod.h" | 23 #include "testing/gtest/include/gtest/gtest_prod.h" |
23 | 24 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 // Returns true if the bookmark bar should be floating on the page (for | 144 // Returns true if the bookmark bar should be floating on the page (for |
144 // NTP). | 145 // NTP). |
145 bool ShouldBeFloating(); | 146 bool ShouldBeFloating(); |
146 // Update the floating state (either enable or disable it, or do nothing). | 147 // Update the floating state (either enable or disable it, or do nothing). |
147 void UpdateFloatingState(); | 148 void UpdateFloatingState(); |
148 | 149 |
149 // Turns on or off the app_paintable flag on |event_box_|, depending on our | 150 // Turns on or off the app_paintable flag on |event_box_|, depending on our |
150 // state. | 151 // state. |
151 void UpdateEventBoxPaintability(); | 152 void UpdateEventBoxPaintability(); |
152 | 153 |
154 // Queue a paint on the event box. | |
155 void PaintEventBox(); | |
156 | |
157 // Finds the size of the current tab contents. If the size cannot be found, | |
158 // DCHECKs and returns false. Otherwise, sets |size| to the correct value. | |
159 bool GetTabContentsSize(gfx::Size* size); | |
160 | |
153 // Overridden from BookmarkModelObserver: | 161 // Overridden from BookmarkModelObserver: |
154 | 162 |
155 // Invoked when the bookmark model has finished loading. Creates a button | 163 // Invoked when the bookmark model has finished loading. Creates a button |
156 // for each of the children of the root node from the model. | 164 // for each of the children of the root node from the model. |
157 virtual void Loaded(BookmarkModel* model); | 165 virtual void Loaded(BookmarkModel* model); |
158 | 166 |
159 // Invoked when the model is being deleted. | 167 // Invoked when the model is being deleted. |
160 virtual void BookmarkModelBeingDeleted(BookmarkModel* model); | 168 virtual void BookmarkModelBeingDeleted(BookmarkModel* model); |
161 | 169 |
162 // Invoked when a node has moved. | 170 // Invoked when a node has moved. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 // Used for both folder buttons and the toolbar. | 246 // Used for both folder buttons and the toolbar. |
239 static void OnDragReceived(GtkWidget* widget, | 247 static void OnDragReceived(GtkWidget* widget, |
240 GdkDragContext* context, | 248 GdkDragContext* context, |
241 gint x, gint y, | 249 gint x, gint y, |
242 GtkSelectionData* selection_data, | 250 GtkSelectionData* selection_data, |
243 guint target_type, guint time, | 251 guint target_type, guint time, |
244 BookmarkBarGtk* bar); | 252 BookmarkBarGtk* bar); |
245 | 253 |
246 // GtkEventBox callbacks. | 254 // GtkEventBox callbacks. |
247 static gboolean OnEventBoxExpose(GtkWidget* widget, GdkEventExpose* event, | 255 static gboolean OnEventBoxExpose(GtkWidget* widget, GdkEventExpose* event, |
248 BookmarkBarGtk* window); | 256 BookmarkBarGtk* bar); |
249 | 257 |
250 // GtkVSeparator callbacks. | 258 // GtkVSeparator callbacks. |
251 static gboolean OnSeparatorExpose(GtkWidget* widget, GdkEventExpose* event, | 259 static gboolean OnSeparatorExpose(GtkWidget* widget, GdkEventExpose* event, |
252 BookmarkBarGtk* window); | 260 BookmarkBarGtk* window); |
tony
2009/10/26 23:55:30
Nit: want to change this to |bar| as well?
| |
253 | 261 |
262 // Callbacks on our parent widget. | |
263 static void OnParentSizeAllocate(GtkWidget* widget, | |
264 GtkAllocation* allocation, | |
265 BookmarkBarGtk* bar); | |
266 | |
254 #if defined(BROWSER_SYNC) | 267 #if defined(BROWSER_SYNC) |
255 // ProfileSyncServiceObserver method. | 268 // ProfileSyncServiceObserver method. |
256 virtual void OnStateChanged(); | 269 virtual void OnStateChanged(); |
257 | 270 |
258 // Determines whether the sync error button should appear on the bookmarks | 271 // Determines whether the sync error button should appear on the bookmarks |
259 // bar. | 272 // bar. |
260 bool ShouldShowSyncErrorButton(); | 273 bool ShouldShowSyncErrorButton(); |
261 | 274 |
262 // Creates the sync error button and adds it as a child view. | 275 // Creates the sync error button and adds it as a child view. |
263 GtkWidget* CreateSyncErrorButton(); | 276 GtkWidget* CreateSyncErrorButton(); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
344 // Whether we are currently configured as floating (detached from the | 357 // Whether we are currently configured as floating (detached from the |
345 // toolbar). This reflects our actual state, and can be out of sync with | 358 // toolbar). This reflects our actual state, and can be out of sync with |
346 // what ShouldShowFloating() returns. | 359 // what ShouldShowFloating() returns. |
347 bool floating_; | 360 bool floating_; |
348 | 361 |
349 // Used to optimize out |bookmark_toolbar_| size-allocate events we don't | 362 // Used to optimize out |bookmark_toolbar_| size-allocate events we don't |
350 // need to respond to. | 363 // need to respond to. |
351 int last_allocation_width_; | 364 int last_allocation_width_; |
352 | 365 |
353 NotificationRegistrar registrar_; | 366 NotificationRegistrar registrar_; |
367 | |
368 // The size of the tab contents last time we forced a paint. We keep track | |
369 // of this so we don't force too many paints. | |
370 gfx::Size last_tab_contents_size_; | |
371 | |
372 // We post delayed paints using this factory. | |
373 ScopedRunnableMethodFactory<BookmarkBarGtk> event_box_paint_factory_; | |
354 }; | 374 }; |
355 | 375 |
356 #endif // CHROME_BROWSER_GTK_BOOKMARK_BAR_GTK_H_ | 376 #endif // CHROME_BROWSER_GTK_BOOKMARK_BAR_GTK_H_ |
OLD | NEW |