blob: 00f17956aa80d90fa4c21d7348f9868bf43a8932 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_GTK_DOWNLOAD_ITEM_GTK_H_
#define CHROME_BROWSER_GTK_DOWNLOAD_ITEM_GTK_H_
#include <gtk/gtk.h>
#include "app/animation.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/download/download_manager.h"
class BaseDownloadItemModel;
class DownloadShelfContextMenuGtk;
class DownloadShelfGtk;
class NineBox;
class SlideAnimation;
class DownloadItemGtk : public DownloadItem::Observer,
public AnimationDelegate {
public:
// DownloadItemGtk takes ownership of |download_item_model|.
DownloadItemGtk(DownloadShelfGtk* parent_shelf,
BaseDownloadItemModel* download_item_model);
// We put |hbox_| in |parent_shelf| and rely on |parent_shelf| recursively
// destroying its children. Hence we do nothing in the destructor.
~DownloadItemGtk();
// DownloadItem::Observer implementation.
virtual void OnDownloadUpdated(DownloadItem* download);
virtual void OnDownloadOpened(DownloadItem* download) { }
// AnimationDelegate implementation.
virtual void AnimationProgressed(const Animation* animation);
private:
// Functions for controlling the progress animation.
// Repaint the download progress.
void UpdateDownloadProgress();
// Starts a repeating timer for UpdateDownloadProgress.
void StartDownloadProgress();
// Stops the repeating timer.
void StopDownloadProgress();
static void InitNineBoxes();
// Used for the download item's body and menu button.
static gboolean OnExpose(GtkWidget* widget, GdkEventExpose* e,
DownloadItemGtk* download_item);
// Used for the download icon.
static gboolean OnProgressAreaExpose(GtkWidget* widget,
GdkEventExpose* e,
DownloadItemGtk* download_item);
static gboolean OnMenuButtonPressEvent(GtkWidget* button,
GdkEvent* event,
DownloadItemGtk* item);
static void OnShelfResized(GtkWidget *widget,
GtkAllocation *allocation,
DownloadItemGtk* item);
// Nineboxes for the body area.
static NineBox* body_nine_box_normal_;
static NineBox* body_nine_box_prelight_;
static NineBox* body_nine_box_active_;
// Nineboxes for the menu button.
static NineBox* menu_nine_box_normal_;
static NineBox* menu_nine_box_prelight_;
static NineBox* menu_nine_box_active_;
// The shelf on which we are displayed.
DownloadShelfGtk* parent_shelf_;
// The widget that contains the body and menu dropdown.
GtkWidget* hbox_;
// The widget that contains the name of the download and the progress
// animation.
GtkWidget* body_;
// The GtkLabel that holds the download title text.
GtkWidget* name_label_;
// The GtkLabel that holds the status text.
GtkWidget* status_label_;
// The widget that creates a dropdown menu when pressed.
GtkWidget* menu_button_;
// The widget that contains the animation progress and the file's icon
// (as well as the complete animation).
GtkWidget* progress_area_;
// In degrees. Only used for downloads with no known total size.
int progress_angle_;
// The menu that pops down when the user presses |menu_button_|. We do not
// create this until the first time we actually need it.
scoped_ptr<DownloadShelfContextMenuGtk> menu_;
// The download item model we represent.
scoped_ptr<BaseDownloadItemModel> download_model_;
// This is the leftmost widget on |parent_shelf_| that is not a download item.
// We do not want to overlap it.
GtkWidget* bounding_widget_;
// The ID of the handler for the parent shelf's "size-allocate" event. We save
// it so we can disconnect when we are destroyed.
gulong resize_handler_id_;
// The animation when this item is first added to the shelf.
scoped_ptr<SlideAnimation> new_item_animation_;
// Progress animation.
base::RepeatingTimer<DownloadItemGtk> progress_timer_;
// Animation for download complete.
scoped_ptr<SlideAnimation> complete_animation_;
};
#endif // CHROME_BROWSER_GTK_DOWNLOAD_ITEM_GTK_H_
|