OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_UI_GTK_EXTENSIONS_MEDIA_GALLERIES_DIALOG_GTK_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_EXTENSIONS_MEDIA_GALLERIES_DIALOG_GTK_H_ |
6 #define CHROME_BROWSER_UI_GTK_EXTENSIONS_MEDIA_GALLERIES_DIALOG_GTK_H_ | 6 #define CHROME_BROWSER_UI_GTK_EXTENSIONS_MEDIA_GALLERIES_DIALOG_GTK_H_ |
7 | 7 |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "chrome/browser/media_galleries/media_galleries_dialog_controller.h" | 14 #include "chrome/browser/media_galleries/media_galleries_dialog_controller.h" |
15 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" | 15 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" |
16 #include "ui/base/gtk/gtk_signal.h" | 16 #include "ui/base/gtk/gtk_signal.h" |
17 #include "ui/base/gtk/owned_widget_gtk.h" | 17 #include "ui/base/gtk/owned_widget_gtk.h" |
18 | 18 |
19 namespace chrome { | 19 namespace chrome { |
20 | 20 |
21 class MediaGalleriesDialogController; | 21 class MediaGalleriesDialogController; |
22 class MediaGalleriesDialogTest; | 22 class MediaGalleriesDialogTest; |
23 | 23 |
24 // The media galleries configuration view for Gtk. It will immediately show | 24 // The media galleries configuration view for Gtk. It will immediately show |
25 // upon construction. | 25 // upon construction. |
26 class MediaGalleriesDialogGtk : public MediaGalleriesDialog, | 26 class MediaGalleriesDialogGtk : public MediaGalleriesDialog { |
27 public ConstrainedWindowGtkDelegate { | |
28 public: | 27 public: |
29 explicit MediaGalleriesDialogGtk(MediaGalleriesDialogController* controller); | 28 explicit MediaGalleriesDialogGtk(MediaGalleriesDialogController* controller); |
30 virtual ~MediaGalleriesDialogGtk(); | 29 virtual ~MediaGalleriesDialogGtk(); |
31 | 30 |
32 // MediaGalleriesDialog implementation: | 31 // MediaGalleriesDialog implementation: |
33 virtual void UpdateGallery(const MediaGalleryPrefInfo* gallery, | 32 virtual void UpdateGallery(const MediaGalleryPrefInfo* gallery, |
34 bool permitted) OVERRIDE; | 33 bool permitted) OVERRIDE; |
35 virtual void ForgetGallery(const MediaGalleryPrefInfo* gallery) OVERRIDE; | 34 virtual void ForgetGallery(const MediaGalleryPrefInfo* gallery) OVERRIDE; |
36 | 35 |
37 // ConstrainedWindowGtkDelegate implementation: | |
38 virtual GtkWidget* GetWidgetRoot() OVERRIDE; | |
39 virtual GtkWidget* GetFocusWidget() OVERRIDE; | |
40 virtual void DeleteDelegate() OVERRIDE; | |
41 | |
42 // Event callbacks. | 36 // Event callbacks. |
43 CHROMEGTK_CALLBACK_0(MediaGalleriesDialogGtk, void, OnToggled); | 37 CHROMEGTK_CALLBACK_0(MediaGalleriesDialogGtk, void, OnToggled); |
44 CHROMEGTK_CALLBACK_0(MediaGalleriesDialogGtk, void, OnAddFolder); | 38 CHROMEGTK_CALLBACK_0(MediaGalleriesDialogGtk, void, OnAddFolder); |
45 CHROMEGTK_CALLBACK_0(MediaGalleriesDialogGtk, void, OnConfirm); | 39 CHROMEGTK_CALLBACK_0(MediaGalleriesDialogGtk, void, OnConfirm); |
46 CHROMEGTK_CALLBACK_0(MediaGalleriesDialogGtk, void, OnCancel); | 40 CHROMEGTK_CALLBACK_0(MediaGalleriesDialogGtk, void, OnCancel); |
47 | 41 |
48 private: | 42 private: |
49 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, InitializeCheckboxes); | 43 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, InitializeCheckboxes); |
50 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, ToggleCheckboxes); | 44 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, ToggleCheckboxes); |
51 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, UpdateAdds); | 45 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, UpdateAdds); |
52 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, ForgetDeletes); | 46 FRIEND_TEST_ALL_PREFIXES(MediaGalleriesDialogTest, ForgetDeletes); |
53 | 47 |
54 typedef std::map<const MediaGalleryPrefInfo*, GtkWidget*> CheckboxMap; | 48 typedef std::map<const MediaGalleryPrefInfo*, GtkWidget*> CheckboxMap; |
55 | 49 |
56 // Creates the widget hierarchy. | 50 // Creates the widget hierarchy. |
57 void InitWidgets(); | 51 void InitWidgets(); |
58 | 52 |
59 // Updates the state of the confirm button. It will be disabled when | 53 // Updates the state of the confirm button. It will be disabled when |
60 void UpdateConfirmButtonState(); | 54 void UpdateConfirmButtonState(); |
61 | 55 |
| 56 CHROMEGTK_CALLBACK_0(MediaGalleriesDialogGtk, void, OnDestroy); |
| 57 |
62 MediaGalleriesDialogController* controller_; | 58 MediaGalleriesDialogController* controller_; |
63 GtkWidget* window_; | 59 GtkWidget* window_; |
64 | 60 |
65 // The root widget for the dialog. | 61 // The root widget for the dialog. |
66 ui::OwnedWidgetGtk contents_; | 62 ui::OwnedWidgetGtk contents_; |
67 | 63 |
68 // The confirm button. | 64 // The confirm button. |
69 GtkWidget* confirm_; | 65 GtkWidget* confirm_; |
70 | 66 |
71 // This widget holds all the checkboxes. | 67 // This widget holds all the checkboxes. |
72 GtkWidget* checkbox_container_; | 68 GtkWidget* checkbox_container_; |
73 | 69 |
74 // A map from MediaGalleryPrefInfo struct (owned by controller) to the | 70 // A map from MediaGalleryPrefInfo struct (owned by controller) to the |
75 // GtkCheckButton that controls it. | 71 // GtkCheckButton that controls it. |
76 CheckboxMap checkbox_map_; | 72 CheckboxMap checkbox_map_; |
77 | 73 |
78 // When true, checkbox toggles are ignored (used when updating the UI). | 74 // When true, checkbox toggles are ignored (used when updating the UI). |
79 bool ignore_toggles_; | 75 bool ignore_toggles_; |
80 | 76 |
81 // True if the user has pressed accept. | 77 // True if the user has pressed accept. |
82 bool accepted_; | 78 bool accepted_; |
83 | 79 |
84 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogGtk); | 80 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesDialogGtk); |
85 }; | 81 }; |
86 | 82 |
87 } // namespace chrome | 83 } // namespace chrome |
88 | 84 |
89 #endif // CHROME_BROWSER_UI_GTK_EXTENSIONS_MEDIA_GALLERIES_DIALOG_GTK_H_ | 85 #endif // CHROME_BROWSER_UI_GTK_EXTENSIONS_MEDIA_GALLERIES_DIALOG_GTK_H_ |
OLD | NEW |