~roignac/software-center/bug-630731-free-software-view

« back to all changes in this revision

Viewing changes to softwarecenter/ui/gtk3/panes/softwarepane.py

  • Committer: Michael Vogt
  • Date: 2011-07-22 16:15:26 UTC
  • mfrom: (1917.4.43 lobby-aesthetics)
  • Revision ID: michael.vogt@ubuntu.com-20110722161526-fuwe66wp1x0qq5zr
mergedĀ lp:~mmcg069/software-center/the-aestheticsĀ 

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
        self.add_to_launcher_requested = False
87
87
 
88
88
 
89
 
class DefaultPages:
90
 
    # pages for the spinner notebook
91
 
    APPVIEW = 0
92
 
    DETAILS = 1
93
 
    SPINNER = 2
94
 
 
95
 
 
96
89
class DisplayState(object):
97
90
 
98
91
    def __init__(self):
107
100
        return
108
101
 
109
102
    def __str__(self):
110
 
        s = '%s %s "%s" %s' % (self.category, self.subcategory, self.search_term, self.application)
 
103
        s = '%s %s "%s" %s %s' % (self.category,
 
104
                                  self.subcategory,
 
105
                                  self.search_term,
 
106
                                  self.application,
 
107
                                  self.channel,)
111
108
        return s
112
109
 
113
110
    def copy(self):
114
111
        state = DisplayState()
 
112
        state.channel = self.channel
115
113
        state.category = self.category
116
114
        state.subcategory = self.subcategory
117
115
        state.search_term = self.search_term
121
119
        return state
122
120
 
123
121
    def reset(self):
 
122
        self.channel = None
124
123
        self.category = None
125
124
        self.subcategory = None
126
125
        self.search_term = ""
132
131
class SoftwarePane(Gtk.VBox, BasePane):
133
132
    """ Common base class for InstalledPane, AvailablePane and ChannelPane"""
134
133
 
 
134
    class Pages:
 
135
        NAMES = ('appview', 'details', 'spinner')
 
136
        APPVIEW = 0
 
137
        DETAILS = 1
 
138
        SPINNER = 2
 
139
 
135
140
    __gsignals__ = {
136
141
        "app-list-changed" : (GObject.SignalFlags.RUN_LAST,
137
142
                              None, 
140
145
    }
141
146
    PADDING = 6
142
147
 
143
 
    def __init__(
144
 
            self, cache, db, distro, icons, datadir,
145
 
            show_ratings=True, store=None):
 
148
    def __init__(self, cache, db, distro, icons, datadir, show_ratings=True, store=None):
146
149
 
147
150
        Gtk.VBox.__init__(self)
148
151
        BasePane.__init__(self)
245
248
        self.purchase_view.connect("purchase-cancelled-by-user", self.on_purchase_cancelled_by_user)
246
249
        # when the cache changes, refresh the app list
247
250
        self.cache.connect("cache-ready", self.on_cache_ready)
248
 
        
 
251
 
249
252
        # aptdaemon
250
253
        self.backend.connect("transaction-started", self.on_transaction_started)
251
254
        self.backend.connect("transaction-finished", self.on_transaction_finished)
298
301
        self.state.application = app
299
302
 
300
303
        vm = get_viewmanager()
301
 
        vm.display_page(self, DefaultPages.DETAILS, self.state, self.display_details_page)
 
304
        vm.display_page(self, SoftwarePane.Pages.DETAILS, self.state, self.display_details_page)
302
305
 
303
306
    def on_purchase_requested(self, widget, app, url):
304
307
 
308
311
        
309
312
    def on_purchase_succeeded(self, widget):
310
313
        # switch to the details page to display the transaction is in progress
311
 
        self.notebook.set_current_page(DefaultPages.DETAILS)
 
314
        self.notebook.set_current_page(SoftwarePane.Pages.DETAILS)
312
315
        
313
316
    def on_purchase_failed(self, widget):
314
317
        # return to the the appdetails view via the button to reset it
489
492
        if not self.state.search_term:
490
493
            self.action_bar.clear()
491
494
        self.spinner_view.stop()
492
 
        self.spinner_notebook.set_current_page(DefaultPages.SPINNER)
 
495
        self.spinner_notebook.set_current_page(SoftwarePane.Pages.SPINNER)
493
496
        # "mask" the spinner view momentarily to prevent it from flashing into
494
497
        # view in the case of short delays where it isn't actually needed
495
498
        GObject.timeout_add(100, self._unmask_appview_spinner)
500
503
    def hide_appview_spinner(self):
501
504
        """ hide the spinner and display the appview in the panel """
502
505
        self.spinner_view.stop()
503
 
        self.spinner_notebook.set_current_page(DefaultPages.APPVIEW)
 
506
        self.spinner_notebook.set_current_page(
 
507
                                        SoftwarePane.Pages.APPVIEW)
504
508
 
505
509
    def set_section(self, section):
506
510
        self.section = section