~ubuntu-branches/ubuntu/quantal/software-center/quantal

« back to all changes in this revision

Viewing changes to softwarecenter/ui/gtk3/widgets/spinner.py

  • Committer: Package Import Robot
  • Author(s): Michael Vogt, Robert Roth, Sebastian Heinlein, Robert Ancell, Michael Vogt
  • Date: 2012-06-01 19:54:38 UTC
  • mfrom: (192.1.1 precise-proposed)
  • Revision ID: package-import@ubuntu.com-20120601195438-wvbelmfgll4h1kuq
Tags: 5.3.0
[ Robert Roth ]
* lp:~evfool/software-center/lp872760:
  - Updated the category name for the RasterGraphics subcategory 
    from Painting & Editing to Painting (LP: #872760)
* lp:~evfool/software-center/lp927426:
  - Changed the reference to store to Software Center, as requested in 
    bug LP: #927426
* lp:~evfool/software-center/specs-update:
  - Moved the recommended applications section after the package details
  - Moved the addon status bar after the addons list
  - Aligned the star ratings widget vertically with the titles
  - Added some vertical padding before the star ratings widget to look 
     bette
* lp:~evfool/software-center/history-enhancements:
  - display text-sized icons in history, not double-sized ones
  - use padding between the icon and the package name
  - right-align the time of the history action
  - display the action +time (installed/updated/removed) if the 
    filter is all changes, otherwise only display the time
  - removed markup from the translatable string, to avoid translation
    mistakes with markup

[ Sebastian Heinlein ]
* lp:~glatzor/software-center/remove-workaround-747172:
  - remove old workaround that should be no longer needed (LP: #747172)
    
[ Robert Ancell ]
* lp:~robert-ancell/software-center/no-lpi:
  - Drop Launchpad integration

[ Michael Vogt ]
* lp:~mvo/software-center/piston-generic-helper-offline-mode:
  - add support for offline mode to the generic helper just like
    for piston_get_reviews_helper.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
import gi
20
20
gi.require_version("Gtk", "3.0")
21
 
import os
22
21
 
23
22
from gi.repository import Gtk, GObject
24
23
 
 
24
from softwarecenter.enums import SOFTWARE_CENTER_DEBUG_TABS
 
25
 
25
26
 
26
27
class SpinnerView(Gtk.Viewport):
27
 
    """
28
 
    a panel that contains a spinner preset to a standard size and centered
29
 
    an optional label_text value can be specified for display with the spinner
30
 
    """
 
28
    """A panel that contains a spinner with an optional legend.
 
29
 
 
30
    The spinner is preset to a standard size and centered. An optional
 
31
    label_text value can be specified for display with the spinner.
 
32
 
 
33
    """
 
34
 
31
35
    def __init__(self, label_text=""):
32
36
        Gtk.Viewport.__init__(self)
33
37
        self.spinner = Gtk.Spinner()
48
52
        self.set_shadow_type(Gtk.ShadowType.NONE)
49
53
 
50
54
    def start_and_show(self):
51
 
        """
52
 
        start the spinner and show it
53
 
        """
 
55
        """Start the spinner and show it."""
54
56
        self.spinner.start()
55
57
        self.spinner.show()
56
58
 
57
59
    def stop_and_hide(self):
58
 
        """
59
 
        stop the spinner and hide it
60
 
        """
 
60
        """Stop the spinner and hide it."""
61
61
        self.spinner.stop()
62
62
        self.spinner.hide()
63
63
 
64
64
    def set_text(self, spinner_text=""):
65
 
        """
66
 
        useful for adding/removing/changing the label text after the spinner
67
 
        instance has been created
68
 
        """
 
65
        """Add/remove/change this spinner's label text."""
69
66
        self.spinner_label.set_markup('<big>%s</big>' % spinner_text)
70
67
 
 
68
    def get_text(self):
 
69
        """Return the spinner's currently set label text."""
 
70
        return self.spinner_label.get_text()
 
71
 
71
72
 
72
73
class SpinnerNotebook(Gtk.Notebook):
73
74
    """ this provides a Gtk.Notebook that contains a content page
78
79
 
79
80
    def __init__(self, content, msg=""):
80
81
        Gtk.Notebook.__init__(self)
 
82
        self._last_timeout_id = None
81
83
        self.spinner_view = SpinnerView(msg)
82
84
        # its critical to show() the spinner early as otherwise
83
85
        # gtk_notebook_set_active_page() will not switch to it
84
86
        self.spinner_view.show()
85
 
        if not "SOFTWARE_CENTER_DEBUG_TABS" in os.environ:
 
87
        if not SOFTWARE_CENTER_DEBUG_TABS:
86
88
            self.set_show_tabs(False)
87
89
        self.set_show_border(False)
88
90
        self.append_page(content, Gtk.Label("content"))
91
93
    def _unmask_view_spinner(self):
92
94
        # start is actually start_and_show()
93
95
        self.spinner_view.start_and_show()
 
96
        self.set_current_page(self.SPINNER_PAGE)
 
97
        self._last_timeout_id = None
94
98
        return False
95
99
 
96
100
    def show_spinner(self, msg=""):
100
104
        # "mask" the spinner view momentarily to prevent it from flashing into
101
105
        # view in the case of short delays where it isn't actually needed
102
106
        self.spinner_view.stop_and_hide()
103
 
        GObject.timeout_add(100, self._unmask_view_spinner)
104
 
        self.set_current_page(self.SPINNER_PAGE)
 
107
        self._last_timeout_id = GObject.timeout_add(250,
 
108
                                                    self._unmask_view_spinner)
105
109
 
106
110
    def hide_spinner(self):
107
111
        """ hide the spinner page again and show the content page """
 
112
        if self._last_timeout_id is not None:
 
113
            GObject.source_remove(self._last_timeout_id)
 
114
            self._last_timeout_id = None
108
115
        self.spinner_view.stop_and_hide()
109
116
        self.set_current_page(self.CONTENT_PAGE)
110
117