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 bookmark bubble, the dialog box |
| 6 // presented to create or edit a bookmark. There can only ever be a single |
| 7 // bubble open, so the class presents only static methods, and handles the |
| 8 // singleton behavior for you. It also handles the object and widget |
| 9 // lifetimes, destroying everything and possibly committing any changes when |
| 10 // the bubble is closed. |
| 11 |
5 #ifndef CHROME_BROWSER_GTK_BOOKMARK_BUBBLE_GTK_H_ | 12 #ifndef CHROME_BROWSER_GTK_BOOKMARK_BUBBLE_GTK_H_ |
6 #define CHROME_BROWSER_GTK_BOOKMARK_BUBBLE_GTK_H_ | 13 #define CHROME_BROWSER_GTK_BOOKMARK_BUBBLE_GTK_H_ |
7 | 14 |
| 15 #include <gtk/gtk.h> |
| 16 |
8 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
| 18 #include "chrome/browser/gtk/info_bubble_gtk.h" |
9 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
10 | 20 |
11 typedef struct _GtkWidget GtkWidget; | |
12 | |
13 class Profile; | 21 class Profile; |
14 namespace gfx { | 22 namespace gfx { |
15 class Rect; | 23 class Rect; |
16 } | 24 } |
17 | 25 |
18 class BookmarkBubbleGtk { | 26 class BookmarkBubbleGtk : public InfoBubbleGtkDelegate { |
19 public: | 27 public: |
| 28 // Shows the bookmark bubble, pointing at |rect|. |
20 static void Show(const gfx::Rect& rect, | 29 static void Show(const gfx::Rect& rect, |
21 Profile* profile, | 30 Profile* profile, |
22 const GURL& url, | 31 const GURL& url, |
23 bool newly_bookmarked); | 32 bool newly_bookmarked); |
| 33 |
| 34 // Implements the InfoBubbleGtkDelegate. We are notified when the bubble |
| 35 // is about to be closed, so we have a chance to save any state / input in |
| 36 // our widgets before they are destroyed. |
| 37 virtual void InfoBubbleClosing(InfoBubbleGtk* info_bubble, |
| 38 bool closed_by_escape); |
| 39 |
| 40 private: |
| 41 BookmarkBubbleGtk(const gfx::Rect& rect, |
| 42 Profile* profile, |
| 43 const GURL& url, |
| 44 bool newly_bookmarked); |
| 45 ~BookmarkBubbleGtk(); |
| 46 |
| 47 static gboolean HandleDestroyThunk(GtkWidget* widget, |
| 48 gpointer userdata) { |
| 49 return reinterpret_cast<BookmarkBubbleGtk*>(userdata)-> |
| 50 HandleDestroy(); |
| 51 } |
| 52 // Notified when |content_| is destroyed so we can delete our instance. |
| 53 gboolean HandleDestroy(); |
| 54 |
| 55 // The URL of the bookmark. |
| 56 GURL url_; |
| 57 // Our current profile (used to access the bookmark system). |
| 58 Profile* profile_; |
| 59 // Whether the bubble is creating or editing an existing bookmark. |
| 60 bool newly_bookmarked_; |
| 61 |
| 62 // We let the InfoBubble own our content, and then we delete ourself |
| 63 // when the widget is destroyed (when the InfoBubble is destroyed). |
| 64 GtkWidget* content_; |
| 65 |
| 66 // The combo box for selecting the bookmark folder. |
| 67 GtkWidget* combo_; |
| 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleGtk); |
24 }; | 70 }; |
25 | 71 |
26 #endif // CHROME_BROWSER_GTK_BOOKMARK_BUBBLE_GTK_H_ | 72 #endif // CHROME_BROWSER_GTK_BOOKMARK_BUBBLE_GTK_H_ |
OLD | NEW |