| 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 // This is the GTK implementation of the First Run bubble, the dialog box | 5 // This is the GTK implementation of the First Run bubble, the dialog box |
| 6 // presented on first run of Chromium. There can only ever be a single | 6 // presented on first run of Chromium. There can only ever be a single |
| 7 // bubble open, so the class presents only static methods. | 7 // bubble open, so the class presents only static methods. |
| 8 | 8 |
| 9 #ifndef CHROME_BROWSER_GTK_FIRST_RUN_BUBBLE_GTK_H_ | 9 #ifndef CHROME_BROWSER_GTK_FIRST_RUN_BUBBLE_H_ |
| 10 #define CHROME_BROWSER_GTK_FIRST_RUN_BUBBLE_GTK_H_ | 10 #define CHROME_BROWSER_GTK_FIRST_RUN_BUBBLE_H_ |
| 11 | 11 |
| 12 #include <gtk/gtk.h> | 12 #include <gtk/gtk.h> |
| 13 | 13 |
| 14 #include <vector> |
| 15 |
| 14 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
| 15 #include "chrome/browser/gtk/info_bubble_gtk.h" | 17 #include "chrome/browser/gtk/info_bubble_gtk.h" |
| 16 #include "chrome/browser/profile.h" | 18 #include "chrome/browser/profile.h" |
| 19 #include "chrome/common/notification_observer.h" |
| 20 #include "chrome/common/notification_registrar.h" |
| 17 | 21 |
| 18 class FirstRunBubble : public InfoBubbleGtkDelegate { | 22 class FirstRunBubble : public InfoBubbleGtkDelegate, |
| 23 public NotificationObserver { |
| 19 public: | 24 public: |
| 20 // Shows the first run bubble, pointing at |rect|. | 25 // Shows the first run bubble, pointing at |rect|. |
| 21 static void Show(Profile* profile, | 26 static void Show(Profile* profile, |
| 22 GtkWindow* parent, | 27 GtkWindow* parent, |
| 23 const gfx::Rect& rect, | 28 const gfx::Rect& rect, |
| 24 bool use_OEM_bubble); | 29 bool use_OEM_bubble); |
| 25 | 30 |
| 26 // Implements the InfoBubbleGtkDelegate. We are notified when the bubble | 31 // Implements the InfoBubbleGtkDelegate. We are notified when the bubble |
| 27 // is about to be closed. | 32 // is about to be closed. |
| 28 virtual void InfoBubbleClosing(InfoBubbleGtk* info_bubble, | 33 virtual void InfoBubbleClosing(InfoBubbleGtk* info_bubble, |
| 29 bool closed_by_escape); | 34 bool closed_by_escape); |
| 30 virtual bool CloseOnEscape() { return true; } | 35 virtual bool CloseOnEscape() { return true; } |
| 31 | 36 |
| 37 // Overridden from NotificationObserver: |
| 38 virtual void Observe(NotificationType type, |
| 39 const NotificationSource& source, |
| 40 const NotificationDetails& details); |
| 41 |
| 32 private: | 42 private: |
| 33 FirstRunBubble(Profile* profile, | 43 FirstRunBubble(Profile* profile, |
| 34 GtkWindow* parent, | 44 GtkWindow* parent, |
| 35 const gfx::Rect& rect); | 45 const gfx::Rect& rect); |
| 36 ~FirstRunBubble() { } | 46 ~FirstRunBubble() { } |
| 37 | 47 |
| 38 static void HandleChangeButtonThunk(GtkWidget* widget, gpointer user_data) { | 48 static void HandleChangeButtonThunk(GtkWidget* widget, gpointer user_data) { |
| 39 reinterpret_cast<FirstRunBubble*>(user_data)->HandleChangeButton(); | 49 reinterpret_cast<FirstRunBubble*>(user_data)->HandleChangeButton(); |
| 40 } | 50 } |
| 41 void HandleChangeButton(); | 51 void HandleChangeButton(); |
| 42 | 52 |
| 43 static void HandleDestroyThunk(GtkWidget* widget, gpointer userdata) { | 53 static void HandleDestroyThunk(GtkWidget* widget, gpointer userdata) { |
| 44 reinterpret_cast<FirstRunBubble*>(userdata)->HandleDestroy(); | 54 reinterpret_cast<FirstRunBubble*>(userdata)->HandleDestroy(); |
| 45 } | 55 } |
| 46 void HandleDestroy(); | 56 void HandleDestroy(); |
| 47 | 57 |
| 48 static void HandleKeepButtonThunk(GtkWidget* widget, gpointer user_data) { | 58 static void HandleKeepButtonThunk(GtkWidget* widget, gpointer user_data) { |
| 49 reinterpret_cast<FirstRunBubble*>(user_data)->HandleKeepButton(); | 59 reinterpret_cast<FirstRunBubble*>(user_data)->HandleKeepButton(); |
| 50 } | 60 } |
| 51 void HandleKeepButton(); | 61 void HandleKeepButton(); |
| 52 | 62 |
| 53 // Our current profile. | 63 // Our current profile. |
| 54 Profile* profile_; | 64 Profile* profile_; |
| 55 | 65 |
| 66 // Provides colors and stuff. |
| 67 GtkThemeProvider* theme_provider_; |
| 68 |
| 56 // The toplevel window our dialogs should be transient for. | 69 // The toplevel window our dialogs should be transient for. |
| 57 GtkWindow* parent_; | 70 GtkWindow* parent_; |
| 58 | 71 |
| 59 // We let the InfoBubble own our content, and then we delete ourself | 72 // We let the InfoBubble own our content, and then we delete ourself |
| 60 // when the widget is destroyed (when the InfoBubble is destroyed). | 73 // when the widget is destroyed (when the InfoBubble is destroyed). |
| 61 GtkWidget* content_; | 74 GtkWidget* content_; |
| 62 | 75 |
| 76 // The various labels in the interface. We keep track of them for theme |
| 77 // changes. |
| 78 std::vector<GtkWidget*> labels_; |
| 79 |
| 63 InfoBubbleGtk* bubble_; | 80 InfoBubbleGtk* bubble_; |
| 64 | 81 |
| 82 NotificationRegistrar registrar_; |
| 83 |
| 65 DISALLOW_COPY_AND_ASSIGN(FirstRunBubble); | 84 DISALLOW_COPY_AND_ASSIGN(FirstRunBubble); |
| 66 }; | 85 }; |
| 67 | 86 |
| 68 #endif // CHROME_BROWSER_GTK_FIRST_RUN_BUBBLE_GTK_H_ | 87 #endif // CHROME_BROWSER_GTK_FIRST_RUN_BUBBLE_H_ |
| OLD | NEW |