| 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_DOWNLOAD_ITEM_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_DOWNLOAD_ITEM_GTK_H_ |
| 6 #define CHROME_BROWSER_GTK_DOWNLOAD_ITEM_GTK_H_ | 6 #define CHROME_BROWSER_GTK_DOWNLOAD_ITEM_GTK_H_ |
| 7 | 7 |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include "app/animation.h" | 10 #include "app/animation.h" |
| 11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
| 12 #include "chrome/browser/download/download_manager.h" | 12 #include "chrome/browser/download/download_manager.h" |
| 13 #include "chrome/browser/icon_manager.h" | 13 #include "chrome/browser/icon_manager.h" |
| 14 #include "chrome/common/owned_widget_gtk.h" | 14 #include "chrome/common/owned_widget_gtk.h" |
| 15 | 15 |
| 16 class BaseDownloadItemModel; | 16 class BaseDownloadItemModel; |
| 17 class DownloadShelfContextMenuGtk; | 17 class DownloadShelfContextMenuGtk; |
| 18 class DownloadShelfGtk; | 18 class DownloadShelfGtk; |
| 19 class GtkThemeProperties; |
| 19 class NineBox; | 20 class NineBox; |
| 20 class SkBitmap; | 21 class SkBitmap; |
| 21 class SlideAnimation; | 22 class SlideAnimation; |
| 22 | 23 |
| 23 class DownloadItemGtk : public DownloadItem::Observer, | 24 class DownloadItemGtk : public DownloadItem::Observer, |
| 24 public AnimationDelegate { | 25 public AnimationDelegate { |
| 25 public: | 26 public: |
| 26 // DownloadItemGtk takes ownership of |download_item_model|. | 27 // DownloadItemGtk takes ownership of |download_item_model|. |
| 27 DownloadItemGtk(DownloadShelfGtk* parent_shelf, | 28 DownloadItemGtk(DownloadShelfGtk* parent_shelf, |
| 28 BaseDownloadItemModel* download_item_model); | 29 BaseDownloadItemModel* download_item_model); |
| 29 | 30 |
| 30 // Destroys all widgets belonging to this DownloadItemGtk. | 31 // Destroys all widgets belonging to this DownloadItemGtk. |
| 31 ~DownloadItemGtk(); | 32 ~DownloadItemGtk(); |
| 32 | 33 |
| 33 // DownloadItem::Observer implementation. | 34 // DownloadItem::Observer implementation. |
| 34 virtual void OnDownloadUpdated(DownloadItem* download); | 35 virtual void OnDownloadUpdated(DownloadItem* download); |
| 35 virtual void OnDownloadOpened(DownloadItem* download) { } | 36 virtual void OnDownloadOpened(DownloadItem* download) { } |
| 36 | 37 |
| 37 // AnimationDelegate implementation. | 38 // AnimationDelegate implementation. |
| 38 virtual void AnimationProgressed(const Animation* animation); | 39 virtual void AnimationProgressed(const Animation* animation); |
| 39 | 40 |
| 41 // Changes the color of the background shelf. |
| 42 void UserChangedTheme(GtkThemeProperties* properties); |
| 43 |
| 40 // Called when the icon manager has finished loading the icon. We take | 44 // Called when the icon manager has finished loading the icon. We take |
| 41 // ownership of |icon_bitmap|. | 45 // ownership of |icon_bitmap|. |
| 42 void OnLoadIconComplete(IconManager::Handle handle, SkBitmap* icon_bitmap); | 46 void OnLoadIconComplete(IconManager::Handle handle, SkBitmap* icon_bitmap); |
| 43 | 47 |
| 44 private: | 48 private: |
| 45 friend class DownloadShelfContextMenuGtk; | 49 friend class DownloadShelfContextMenuGtk; |
| 46 | 50 |
| 47 DownloadItem* get_download(); | 51 DownloadItem* get_download(); |
| 48 | 52 |
| 49 // Returns true IFF the download is dangerous and unconfirmed. | 53 // Returns true IFF the download is dangerous and unconfirmed. |
| 50 bool IsDangerous(); | 54 bool IsDangerous(); |
| 51 | 55 |
| 52 // Functions for controlling the progress animation. | 56 // Functions for controlling the progress animation. |
| 53 // Repaint the download progress. | 57 // Repaint the download progress. |
| 54 void UpdateDownloadProgress(); | 58 void UpdateDownloadProgress(); |
| 55 | 59 |
| 56 // Starts a repeating timer for UpdateDownloadProgress. | 60 // Starts a repeating timer for UpdateDownloadProgress. |
| 57 void StartDownloadProgress(); | 61 void StartDownloadProgress(); |
| 58 | 62 |
| 59 // Stops the repeating timer. | 63 // Stops the repeating timer. |
| 60 void StopDownloadProgress(); | 64 void StopDownloadProgress(); |
| 61 | 65 |
| 62 // Ask the icon manager to asynchronously start loading the icon for the file. | 66 // Ask the icon manager to asynchronously start loading the icon for the file. |
| 63 void LoadIcon(); | 67 void LoadIcon(); |
| 64 | 68 |
| 69 // Sets the name label to the correct color. |
| 70 void UpdateNameLabel(); |
| 71 |
| 72 // Sets the text with the correct color if |status_label| exists. |
| 73 void UpdateStatusLabel(GtkWidget* status_label, |
| 74 const std::string& status_text); |
| 75 |
| 65 static void InitNineBoxes(); | 76 static void InitNineBoxes(); |
| 66 | 77 |
| 67 // Used for the download item's body and menu button. | 78 // Used for the download item's body and menu button. |
| 68 static gboolean OnExpose(GtkWidget* widget, GdkEventExpose* e, | 79 static gboolean OnExpose(GtkWidget* widget, GdkEventExpose* e, |
| 69 DownloadItemGtk* download_item); | 80 DownloadItemGtk* download_item); |
| 70 | 81 |
| 71 // Called when |body_| is clicked. | 82 // Called when |body_| is clicked. |
| 72 static void OnClick(GtkWidget* widget, DownloadItemGtk* item); | 83 static void OnClick(GtkWidget* widget, DownloadItemGtk* item); |
| 73 | 84 |
| 74 // Used for the download icon. | 85 // Used for the download icon. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // The widget that contains the name of the download and the progress | 125 // The widget that contains the name of the download and the progress |
| 115 // animation. | 126 // animation. |
| 116 OwnedWidgetGtk body_; | 127 OwnedWidgetGtk body_; |
| 117 | 128 |
| 118 // The GtkLabel that holds the download title text. | 129 // The GtkLabel that holds the download title text. |
| 119 GtkWidget* name_label_; | 130 GtkWidget* name_label_; |
| 120 | 131 |
| 121 // The GtkLabel that holds the status text. | 132 // The GtkLabel that holds the status text. |
| 122 GtkWidget* status_label_; | 133 GtkWidget* status_label_; |
| 123 | 134 |
| 135 // The current text of status label |
| 136 std::string status_text_; |
| 137 |
| 124 // The widget that creates a dropdown menu when pressed. | 138 // The widget that creates a dropdown menu when pressed. |
| 125 GtkWidget* menu_button_; | 139 GtkWidget* menu_button_; |
| 126 | 140 |
| 127 // Whether the menu is currently showing for |menu_button_|. Affects how we | 141 // Whether the menu is currently showing for |menu_button_|. Affects how we |
| 128 // draw the button. | 142 // draw the button. |
| 129 bool menu_showing_; | 143 bool menu_showing_; |
| 130 | 144 |
| 145 // Whether we should use the GTK text color |
| 146 bool use_gtk_colors_; |
| 147 |
| 131 // The widget that contains the animation progress and the file's icon | 148 // The widget that contains the animation progress and the file's icon |
| 132 // (as well as the complete animation). | 149 // (as well as the complete animation). |
| 133 OwnedWidgetGtk progress_area_; | 150 OwnedWidgetGtk progress_area_; |
| 134 | 151 |
| 135 // In degrees. Only used for downloads with no known total size. | 152 // In degrees. Only used for downloads with no known total size. |
| 136 int progress_angle_; | 153 int progress_angle_; |
| 137 | 154 |
| 138 // The menu that pops down when the user presses |menu_button_|. We do not | 155 // The menu that pops down when the user presses |menu_button_|. We do not |
| 139 // create this until the first time we actually need it. | 156 // create this until the first time we actually need it. |
| 140 scoped_ptr<DownloadShelfContextMenuGtk> menu_; | 157 scoped_ptr<DownloadShelfContextMenuGtk> menu_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 164 scoped_ptr<SlideAnimation> complete_animation_; | 181 scoped_ptr<SlideAnimation> complete_animation_; |
| 165 | 182 |
| 166 // The file icon for the download. May be null. | 183 // The file icon for the download. May be null. |
| 167 SkBitmap* icon_; | 184 SkBitmap* icon_; |
| 168 | 185 |
| 169 // For canceling an in progress icon request. | 186 // For canceling an in progress icon request. |
| 170 CancelableRequestConsumerT<int, 0> icon_consumer_; | 187 CancelableRequestConsumerT<int, 0> icon_consumer_; |
| 171 }; | 188 }; |
| 172 | 189 |
| 173 #endif // CHROME_BROWSER_GTK_DOWNLOAD_ITEM_GTK_H_ | 190 #endif // CHROME_BROWSER_GTK_DOWNLOAD_ITEM_GTK_H_ |
| OLD | NEW |