| 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_EXTENSION_SHELF_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_EXTENSION_SHELF_GTK_H_ |
| 6 #define CHROME_BROWSER_GTK_EXTENSION_SHELF_GTK_H_ | 6 #define CHROME_BROWSER_GTK_EXTENSION_SHELF_GTK_H_ |
| 7 | 7 |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| 11 | 11 |
| 12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "chrome/browser/extensions/extension_shelf_model.h" | 13 #include "chrome/browser/extensions/extension_shelf_model.h" |
| 14 #include "chrome/common/notification_observer.h" | |
| 15 #include "chrome/common/notification_registrar.h" | |
| 16 #include "chrome/common/owned_widget_gtk.h" | 14 #include "chrome/common/owned_widget_gtk.h" |
| 17 | 15 |
| 18 class Browser; | 16 class Browser; |
| 19 class BrowserWindowGtk; | 17 class BrowserWindowGtk; |
| 20 class CustomContainerButton; | 18 class CustomContainerButton; |
| 21 class NineBox; | 19 class NineBox; |
| 22 class Profile; | 20 class Profile; |
| 23 struct GtkThemeProvider; | 21 struct GtkThemeProvider; |
| 24 | 22 |
| 25 class ExtensionShelfGtk : public ExtensionShelfModelObserver, | 23 class ExtensionShelfGtk : public ExtensionShelfModelObserver { |
| 26 public NotificationObserver { | |
| 27 public: | 24 public: |
| 28 ExtensionShelfGtk(Profile* profile, Browser* browser); | 25 ExtensionShelfGtk(Profile* profile, Browser* browser); |
| 29 virtual ~ExtensionShelfGtk(); | 26 virtual ~ExtensionShelfGtk(); |
| 30 | 27 |
| 31 // Adds this GTK shelf into a sizing box. | 28 // Adds this GTK shelf into a sizing box. |
| 32 void AddShelfToBox(GtkWidget* box); | 29 void AddShelfToBox(GtkWidget* box); |
| 33 | 30 |
| 34 // Change the visibility of the bookmarks bar. (Starts out hidden, per GTK's | 31 // Change the visibility of the bookmarks bar. (Starts out hidden, per GTK's |
| 35 // default behaviour). | 32 // default behaviour). |
| 36 void Show(); | 33 void Show(); |
| 37 void Hide(); | 34 void Hide(); |
| 38 | 35 |
| 39 // ExtensionShelfModelObserver | 36 // ExtensionShelfModelObserver |
| 40 virtual void ToolstripInsertedAt(ExtensionHost* host, int index); | 37 virtual void ToolstripInsertedAt(ExtensionHost* host, int index); |
| 41 virtual void ToolstripRemovingAt(ExtensionHost* host, int index); | 38 virtual void ToolstripRemovingAt(ExtensionHost* host, int index); |
| 42 virtual void ToolstripMoved(ExtensionHost* host, | 39 virtual void ToolstripMoved(ExtensionHost* host, |
| 43 int from_index, | 40 int from_index, |
| 44 int to_index); | 41 int to_index); |
| 45 virtual void ToolstripChanged(ExtensionShelfModel::iterator toolstrip); | 42 virtual void ToolstripChanged(ExtensionShelfModel::iterator toolstrip); |
| 46 virtual void ExtensionShelfEmpty(); | 43 virtual void ExtensionShelfEmpty(); |
| 47 virtual void ShelfModelReloaded(); | 44 virtual void ShelfModelReloaded(); |
| 48 virtual void ShelfModelDeleting(); | 45 virtual void ShelfModelDeleting(); |
| 49 | 46 |
| 50 private: | 47 private: |
| 51 class Toolstrip; | 48 class Toolstrip; |
| 52 | 49 |
| 53 // Create the contents of the extension shelf. | 50 // Create the contents of the extension shelf. |
| 54 void Init(Profile* profile); | 51 void Init(Profile* profile); |
| 55 | 52 |
| 56 // Overridden from NotificationObserver: | |
| 57 virtual void Observe(NotificationType type, | |
| 58 const NotificationSource& source, | |
| 59 const NotificationDetails& details); | |
| 60 | |
| 61 // Loads the background image into memory, or does nothing if already loaded. | |
| 62 void InitBackground(); | |
| 63 | |
| 64 // Determines what is our target height and sets it. | 53 // Determines what is our target height and sets it. |
| 65 void AdjustHeight(); | 54 void AdjustHeight(); |
| 66 | 55 |
| 67 void LoadFromModel(); | 56 void LoadFromModel(); |
| 68 | 57 |
| 69 Toolstrip* ToolstripAtIndex(int index); | 58 Toolstrip* ToolstripAtIndex(int index); |
| 70 | 59 |
| 71 // GtkHBox callbacks. | 60 // GtkHBox callbacks. |
| 72 static gboolean OnHBoxExpose(GtkWidget* widget, GdkEventExpose* event, | 61 static gboolean OnHBoxExpose(GtkWidget* widget, GdkEventExpose* event, |
| 73 ExtensionShelfGtk* window); | 62 ExtensionShelfGtk* window); |
| 74 | 63 |
| 75 Browser* browser_; | 64 Browser* browser_; |
| 76 | 65 |
| 77 // Contains |shelf_hbox_|. Event box exists to prevent leakage of | 66 // Contains |shelf_hbox_|. Event box exists to prevent leakage of |
| 78 // background color from the toplevel application window's GDK window. | 67 // background color from the toplevel application window's GDK window. |
| 79 OwnedWidgetGtk event_box_; | 68 OwnedWidgetGtk event_box_; |
| 80 | 69 |
| 81 // Used to position all children. | 70 // Used to position all children. |
| 82 GtkWidget* shelf_hbox_; | 71 GtkWidget* shelf_hbox_; |
| 83 | 72 |
| 84 GtkThemeProvider* theme_provider_; | 73 GtkThemeProvider* theme_provider_; |
| 85 | 74 |
| 86 // Paints the background for our bookmark bar. | |
| 87 scoped_ptr<NineBox> background_ninebox_; | |
| 88 | |
| 89 NotificationRegistrar registrar_; | |
| 90 | |
| 91 // The model representing the toolstrips on the shelf. | 75 // The model representing the toolstrips on the shelf. |
| 92 ExtensionShelfModel* model_; | 76 ExtensionShelfModel* model_; |
| 93 | 77 |
| 94 // Set of toolstrip views which are really on the shelf. | 78 // Set of toolstrip views which are really on the shelf. |
| 95 std::set<Toolstrip*> toolstrips_; | 79 std::set<Toolstrip*> toolstrips_; |
| 96 | 80 |
| 97 DISALLOW_COPY_AND_ASSIGN(ExtensionShelfGtk); | 81 DISALLOW_COPY_AND_ASSIGN(ExtensionShelfGtk); |
| 98 }; | 82 }; |
| 99 | 83 |
| 100 #endif // CHROME_BROWSER_EXTENSION_SHELF_GTK_H_ | 84 #endif // CHROME_BROWSER_EXTENSION_SHELF_GTK_H_ |
| OLD | NEW |