OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_DOWNLOAD_SHELF_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_DOWNLOAD_SHELF_GTK_H_ |
6 #define CHROME_BROWSER_GTK_DOWNLOAD_SHELF_GTK_H_ | 6 #define CHROME_BROWSER_GTK_DOWNLOAD_SHELF_GTK_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <gtk/gtk.h> | 9 #include "chrome/browser/ui/gtk/download_shelf_gtk.h" |
10 | 10 // TODO(msw): remove this file once all includes have been updated. |
11 #include <vector> | |
12 | |
13 #include "app/gtk_signal.h" | |
14 #include "base/scoped_ptr.h" | |
15 #include "chrome/browser/download/download_shelf.h" | |
16 #include "chrome/browser/gtk/owned_widget_gtk.h" | |
17 #include "chrome/browser/gtk/slide_animator_gtk.h" | |
18 #include "chrome/common/notification_observer.h" | |
19 #include "chrome/common/notification_registrar.h" | |
20 #include "gfx/native_widget_types.h" | |
21 | |
22 class BaseDownloadItemModel; | |
23 class Browser; | |
24 class CustomDrawButton; | |
25 class DownloadItemGtk; | |
26 class GtkThemeProvider; | |
27 class SlideAnimatorGtk; | |
28 | |
29 class DownloadShelfGtk : public DownloadShelf, | |
30 public NotificationObserver, | |
31 public SlideAnimatorGtk::Delegate { | |
32 public: | |
33 explicit DownloadShelfGtk(Browser* browser, gfx::NativeView view); | |
34 | |
35 ~DownloadShelfGtk(); | |
36 | |
37 // DownloadShelf implementation. | |
38 virtual void AddDownload(BaseDownloadItemModel* download_model); | |
39 virtual bool IsShowing() const; | |
40 virtual bool IsClosing() const; | |
41 virtual void Show(); | |
42 virtual void Close(); | |
43 virtual Browser* browser() const; | |
44 | |
45 // SlideAnimatorGtk::Delegate implementation. | |
46 virtual void Closed(); | |
47 | |
48 // Overridden from NotificationObserver: | |
49 virtual void Observe(NotificationType type, | |
50 const NotificationSource& source, | |
51 const NotificationDetails& details); | |
52 | |
53 // Returns the current height of the shelf. | |
54 int GetHeight() const; | |
55 | |
56 private: | |
57 // Remove |download_item| from the download shelf and delete it. | |
58 void RemoveDownloadItem(DownloadItemGtk* download_item); | |
59 | |
60 // Get the hbox download items ought to pack themselves into. | |
61 GtkWidget* GetHBox() const; | |
62 | |
63 // Show more hidden download items if there is enough space in the shelf. | |
64 // It's called when a download item is removed from the shelf or an item's | |
65 // size is changed. | |
66 void MaybeShowMoreDownloadItems(); | |
67 | |
68 CHROMEGTK_CALLBACK_0(DownloadShelfGtk, void, OnButtonClick); | |
69 | |
70 // The browser that owns this download shelf. | |
71 Browser* browser_; | |
72 | |
73 // The top level widget of the shelf. | |
74 scoped_ptr<SlideAnimatorGtk> slide_widget_; | |
75 | |
76 // |items_hbox_| holds the download items. | |
77 OwnedWidgetGtk items_hbox_; | |
78 | |
79 // |shelf_| is the second highest level widget. See the constructor | |
80 // for an explanation of the widget layout. | |
81 OwnedWidgetGtk shelf_; | |
82 | |
83 // Top level event box which draws the one pixel border. | |
84 GtkWidget* top_border_; | |
85 | |
86 // A GtkEventBox which we color. | |
87 GtkWidget* padding_bg_; | |
88 | |
89 // The "Show all downloads..." link. | |
90 GtkWidget* link_button_; | |
91 | |
92 // The 'x' that the user can press to hide the download shelf. | |
93 scoped_ptr<CustomDrawButton> close_button_; | |
94 | |
95 // Keeps track of our current hide/show state. | |
96 bool is_showing_; | |
97 | |
98 // The download items we have added to our shelf. | |
99 std::vector<DownloadItemGtk*> download_items_; | |
100 | |
101 // Gives us our colors and theme information. | |
102 GtkThemeProvider* theme_provider_; | |
103 | |
104 NotificationRegistrar registrar_; | |
105 | |
106 friend class DownloadItemGtk; | |
107 }; | |
108 | 11 |
109 #endif // CHROME_BROWSER_GTK_DOWNLOAD_SHELF_GTK_H_ | 12 #endif // CHROME_BROWSER_GTK_DOWNLOAD_SHELF_GTK_H_ |
OLD | NEW |