Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(646)

Side by Side Diff: chrome/browser/ui/gtk/download/download_started_animation_gtk.cc

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 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 #include "chrome/browser/download/download_started_animation.h" 5 #include "chrome/browser/download/download_started_animation.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "content/browser/tab_contents/tab_contents.h" 10 #include "content/browser/tab_contents/tab_contents.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // Move the arrow to wherever it should currently be. 42 // Move the arrow to wherever it should currently be.
43 void Reposition(); 43 void Reposition();
44 44
45 // Shut down cleanly. 45 // Shut down cleanly.
46 void Close(); 46 void Close();
47 47
48 // Animation implementation. 48 // Animation implementation.
49 virtual void AnimateToState(double state); 49 virtual void AnimateToState(double state);
50 50
51 // NotificationObserver 51 // NotificationObserver
52 virtual void Observe(NotificationType type, 52 virtual void Observe(int type,
53 const NotificationSource& source, 53 const NotificationSource& source,
54 const NotificationDetails& details); 54 const NotificationDetails& details);
55 55
56 // The top level window that floats over the browser and displays the 56 // The top level window that floats over the browser and displays the
57 // image. 57 // image.
58 GtkWidget* popup_; 58 GtkWidget* popup_;
59 59
60 // Dimensions of the image. 60 // Dimensions of the image.
61 int width_; 61 int width_;
62 int height_; 62 int height_;
(...skipping 28 matching lines...) Expand all
91 height_ = gdk_pixbuf_get_height(kDownloadImage); 91 height_ = gdk_pixbuf_get_height(kDownloadImage);
92 92
93 // If we're too small to show the download image, then don't bother - 93 // If we're too small to show the download image, then don't bother -
94 // the shelf will be enough. 94 // the shelf will be enough.
95 tab_contents_->GetContainerBounds(&tab_contents_bounds_); 95 tab_contents_->GetContainerBounds(&tab_contents_bounds_);
96 if (tab_contents_bounds_.height() < height_) 96 if (tab_contents_bounds_.height() < height_)
97 return; 97 return;
98 98
99 registrar_.Add( 99 registrar_.Add(
100 this, 100 this,
101 NotificationType::TAB_CONTENTS_HIDDEN, 101 content::NOTIFICATION_TAB_CONTENTS_HIDDEN,
102 Source<TabContents>(tab_contents_)); 102 Source<TabContents>(tab_contents_));
103 registrar_.Add( 103 registrar_.Add(
104 this, 104 this,
105 NotificationType::TAB_CONTENTS_DESTROYED, 105 content::NOTIFICATION_TAB_CONTENTS_DESTROYED,
106 Source<TabContents>(tab_contents_)); 106 Source<TabContents>(tab_contents_));
107 107
108 // TODO(estade): don't show up on the wrong virtual desktop. 108 // TODO(estade): don't show up on the wrong virtual desktop.
109 109
110 popup_ = gtk_window_new(GTK_WINDOW_POPUP); 110 popup_ = gtk_window_new(GTK_WINDOW_POPUP);
111 GtkWidget* image = gtk_image_new_from_pixbuf(kDownloadImage); 111 GtkWidget* image = gtk_image_new_from_pixbuf(kDownloadImage);
112 gtk_container_add(GTK_CONTAINER(popup_), image); 112 gtk_container_add(GTK_CONTAINER(popup_), image);
113 113
114 // Set the shape of the window to that of the arrow. Areas with 114 // Set the shape of the window to that of the arrow. Areas with
115 // opacity less than 0xff (i.e. <100% opacity) will be transparent. 115 // opacity less than 0xff (i.e. <100% opacity) will be transparent.
(...skipping 27 matching lines...) Expand all
143 static_cast<int>(tab_contents_bounds_.bottom() - 143 static_cast<int>(tab_contents_bounds_.bottom() -
144 height_ - height_ * (1 - GetCurrentValue()))); 144 height_ - height_ * (1 - GetCurrentValue())));
145 } 145 }
146 146
147 void DownloadStartedAnimationGtk::Close() { 147 void DownloadStartedAnimationGtk::Close() {
148 if (!tab_contents_) 148 if (!tab_contents_)
149 return; 149 return;
150 150
151 registrar_.Remove( 151 registrar_.Remove(
152 this, 152 this,
153 NotificationType::TAB_CONTENTS_HIDDEN, 153 content::NOTIFICATION_TAB_CONTENTS_HIDDEN,
154 Source<TabContents>(tab_contents_)); 154 Source<TabContents>(tab_contents_));
155 registrar_.Remove( 155 registrar_.Remove(
156 this, 156 this,
157 NotificationType::TAB_CONTENTS_DESTROYED, 157 content::NOTIFICATION_TAB_CONTENTS_DESTROYED,
158 Source<TabContents>(tab_contents_)); 158 Source<TabContents>(tab_contents_));
159 159
160 tab_contents_ = NULL; 160 tab_contents_ = NULL;
161 gtk_widget_destroy(popup_); 161 gtk_widget_destroy(popup_);
162 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 162 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
163 } 163 }
164 164
165 void DownloadStartedAnimationGtk::AnimateToState(double state) { 165 void DownloadStartedAnimationGtk::AnimateToState(double state) {
166 if (!tab_contents_) 166 if (!tab_contents_)
167 return; 167 return;
168 168
169 if (state >= 1.0) { 169 if (state >= 1.0) {
170 Close(); 170 Close();
171 } else { 171 } else {
172 Reposition(); 172 Reposition();
173 173
174 // Start at zero, peak halfway and end at zero. 174 // Start at zero, peak halfway and end at zero.
175 double opacity = std::min(1.0 - pow(GetCurrentValue() - 0.5, 2) * 4.0, 175 double opacity = std::min(1.0 - pow(GetCurrentValue() - 0.5, 2) * 4.0,
176 static_cast<double>(1.0)); 176 static_cast<double>(1.0));
177 177
178 // This only works when there's a compositing manager running. Oh well. 178 // This only works when there's a compositing manager running. Oh well.
179 gtk_window_set_opacity(GTK_WINDOW(popup_), opacity); 179 gtk_window_set_opacity(GTK_WINDOW(popup_), opacity);
180 } 180 }
181 } 181 }
182 182
183 void DownloadStartedAnimationGtk::Observe(NotificationType type, 183 void DownloadStartedAnimationGtk::Observe(int type,
184 const NotificationSource& source, 184 const NotificationSource& source,
185 const NotificationDetails& details) { 185 const NotificationDetails& details) {
186 Close(); 186 Close();
187 } 187 }
188 188
189 } // namespace 189 } // namespace
190 190
191 // static 191 // static
192 void DownloadStartedAnimation::Show(TabContents* tab_contents) { 192 void DownloadStartedAnimation::Show(TabContents* tab_contents) {
193 // The animation will delete itself. 193 // The animation will delete itself.
194 new DownloadStartedAnimationGtk(tab_contents); 194 new DownloadStartedAnimationGtk(tab_contents);
195 } 195 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698