| 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_TOOLBAR_STAR_TOGGLE_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_TOOLBAR_STAR_TOGGLE_GTK_H_ |
| 6 #define CHROME_BROWSER_GTK_TOOLBAR_STAR_TOGGLE_GTK_H_ | 6 #define CHROME_BROWSER_GTK_TOOLBAR_STAR_TOGGLE_GTK_H_ |
| 7 | 7 |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "chrome/browser/gtk/custom_button.h" | 11 #include "chrome/browser/gtk/custom_button.h" |
| 12 #include "chrome/common/notification_observer.h" |
| 13 #include "chrome/common/notification_registrar.h" |
| 12 #include "chrome/common/owned_widget_gtk.h" | 14 #include "chrome/common/owned_widget_gtk.h" |
| 13 | 15 |
| 14 class BrowserToolbarGtk; | 16 class BrowserToolbarGtk; |
| 17 class GtkThemeProvider; |
| 15 class GURL; | 18 class GURL; |
| 16 | 19 |
| 17 // Displays the bookmark star button, which toggles between two images. | 20 // Displays the bookmark star button, which toggles between two images. |
| 18 class ToolbarStarToggleGtk { | 21 class ToolbarStarToggleGtk : public NotificationObserver { |
| 19 public: | 22 public: |
| 20 ToolbarStarToggleGtk(BrowserToolbarGtk* host); | 23 explicit ToolbarStarToggleGtk(BrowserToolbarGtk* host); |
| 21 ~ToolbarStarToggleGtk(); | 24 ~ToolbarStarToggleGtk(); |
| 22 | 25 |
| 26 // Provide NotificationObserver implementation. |
| 27 virtual void Observe(NotificationType type, |
| 28 const NotificationSource& source, |
| 29 const NotificationDetails& details); |
| 30 |
| 23 // If the bubble isn't showing, shows it above the star button. | 31 // If the bubble isn't showing, shows it above the star button. |
| 24 void ShowStarBubble(const GURL& url, bool newly_bookmarked); | 32 void ShowStarBubble(const GURL& url, bool newly_bookmarked); |
| 25 | 33 |
| 26 void SetStarred(bool starred); | 34 void SetStarred(bool starred); |
| 27 | 35 |
| 28 GtkWidget* widget() const { return widget_.get(); } | 36 GtkWidget* widget() const { return widget_.get(); } |
| 29 | 37 |
| 30 private: | 38 private: |
| 39 // Updates the properties of |widget_| when we would need to change its |
| 40 // state. |
| 41 void UpdateGTKButton(); |
| 42 |
| 31 // Callback for expose, used to draw the custom graphics. | 43 // Callback for expose, used to draw the custom graphics. |
| 32 static gboolean OnExpose(GtkWidget* widget, GdkEventExpose* e, | 44 static gboolean OnExpose(GtkWidget* widget, GdkEventExpose* e, |
| 33 ToolbarStarToggleGtk* obj); | 45 ToolbarStarToggleGtk* obj); |
| 34 | 46 |
| 47 // Used to listen for theme change notifications. |
| 48 NotificationRegistrar registrar_; |
| 49 |
| 35 // The browser toolbar hosting this widget, for getting the current profile. | 50 // The browser toolbar hosting this widget, for getting the current profile. |
| 36 BrowserToolbarGtk* host_; | 51 BrowserToolbarGtk* host_; |
| 37 | 52 |
| 38 // The actual button widget. | 53 // The actual button widget. |
| 39 OwnedWidgetGtk widget_; | 54 OwnedWidgetGtk widget_; |
| 40 | 55 |
| 41 // Whether we show the yellow star. | 56 // Whether we show the yellow star. |
| 42 bool is_starred_; | 57 bool is_starred_; |
| 43 | 58 |
| 59 GtkThemeProvider* theme_provider_; |
| 60 |
| 44 CustomDrawButtonBase unstarred_; | 61 CustomDrawButtonBase unstarred_; |
| 45 CustomDrawButtonBase starred_; | 62 CustomDrawButtonBase starred_; |
| 46 | 63 |
| 47 DISALLOW_EVIL_CONSTRUCTORS(ToolbarStarToggleGtk); | 64 DISALLOW_EVIL_CONSTRUCTORS(ToolbarStarToggleGtk); |
| 48 }; | 65 }; |
| 49 | 66 |
| 50 #endif // CHROME_BROWSER_GTK_TOOLBAR_STAR_TOGGLE_GTK_H_ | 67 #endif // CHROME_BROWSER_GTK_TOOLBAR_STAR_TOGGLE_GTK_H_ |
| OLD | NEW |