1 # -*- coding: utf-8 -*-
3 # gPodder - A media aggregator and podcast client
4 # Copyright (c) 2005-2018 The gPodder Team
6 # gPodder is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # gPodder is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 # widgets.py -- Additional widgets for gPodder
23 # Thomas Perl <thp@gpodder.org> 2009-03-31
27 from gi
.repository
import Gtk
30 class SpinningProgressIndicator(Gtk
.Image
):
31 # Progress indicator loading inspired by glchess from gnome-games-clutter
32 def __init__(self
, size
=32):
33 Gtk
.Image
.__init
__(self
)
38 # Load the progress indicator
39 icon_theme
= Gtk
.IconTheme
.get_default()
42 icon
= icon_theme
.load_icon('process-working', size
, 0)
43 width
, height
= icon
.get_width(), icon
.get_height()
44 if width
< size
or height
< size
:
45 size
= min(width
, height
)
46 for row
in range(height
// size
):
47 for column
in range(width
// size
):
48 frame
= icon
.subpixbuf(column
* size
, row
* size
, size
, size
)
49 self
._frames
.append(frame
)
50 # Remove the first frame (the "idle" icon)
55 # FIXME: This is not very beautiful :/
56 self
.set_from_icon_name('system-run', Gtk
.IconSize
.BUTTON
)
58 def step_animation(self
):
59 if len(self
._frames
) > 1:
61 if self
._frame
_id
>= len(self
._frames
):
63 self
.set_from_pixbuf(self
._frames
[self
._frame
_id
])