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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_GTK_THROBBER_GTK_H_
6 #define CHROME_BROWSER_UI_GTK_THROBBER_GTK_H_
10 #include "base/compiler_specific.h"
11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h"
13 #include "ui/base/gtk/gtk_signal.h"
14 #include "ui/base/gtk/owned_widget_gtk.h"
15 #include "ui/gfx/animation/animation_delegate.h"
16 #include "ui/gfx/animation/slide_animation.h"
17 #include "ui/gfx/image/image.h"
19 class GtkThemeService
;
22 // An animating throbber.
23 class ThrobberGtk
: public gfx::AnimationDelegate
,
24 public content::NotificationObserver
{
26 // |theme_service| must not be NULL.
27 explicit ThrobberGtk(GtkThemeService
* theme_service
);
28 virtual ~ThrobberGtk();
30 // Start or stop the throbbing animation.
34 GtkWidget
* widget() const { return widget_
.get(); }
36 // gfx::AnimationDelegate implementation.
37 virtual void AnimationEnded(const gfx::Animation
* animation
) OVERRIDE
;
38 virtual void AnimationProgressed(const gfx::Animation
* animation
) OVERRIDE
;
40 // content::NotificationObserver implementation.
41 virtual void Observe(int type
,
42 const content::NotificationSource
& source
,
43 const content::NotificationDetails
& details
) OVERRIDE
;
46 CHROMEGTK_CALLBACK_1(ThrobberGtk
, gboolean
, OnExpose
, GdkEventExpose
*);
48 // Initialize the widget.
51 // Load the animation frames from IDR_THROBBER.
54 content::NotificationRegistrar registrar_
;
56 // The theme service. Weak pointer.
57 GtkThemeService
* theme_service_
;
59 // The actual GtkWidget.
60 ui::OwnedWidgetGtk widget_
;
62 // A linear animation over the loaded frames.
63 gfx::SlideAnimation animation_
;
65 // The image containing the throbber frames.
68 // The number of frames in |frames_|.
71 DISALLOW_COPY_AND_ASSIGN(ThrobberGtk
);
74 #endif // CHROME_BROWSER_UI_GTK_THROBBER_GTK_H_