1
# Copyright (C) 2009 Canonical
6
# This program is free software; you can redistribute it and/or modify it under
7
# the terms of the GNU General Public License as published by the Free Software
8
# Foundation; version 3.
10
# This program is distributed in the hope that it will be useful, but WITHOUT
11
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15
# You should have received a copy of the GNU General Public License along with
16
# this program; if not, write to the Free Software Foundation, Inc.,
17
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
from gi.repository import Gtk
21
from softwarecenter.utils import utf8
23
# for DisplayState attribute type-checking
24
from softwarecenter.db.database import Application
25
from softwarecenter.db.categories import Category
26
from softwarecenter.backend.channel import SoftwareChannel
27
from softwarecenter.db.appfilter import AppFilter
30
class DisplayState(object):
31
""" This represents the display state for the undo history """
33
_attrs = {'category': (type(None), Category),
34
'channel': (type(None), SoftwareChannel),
35
'subcategory': (type(None), Category),
36
'search_term': (str,),
37
'application': (type(None), Application),
39
'filter': (type(None), AppFilter),
40
'vadjustment': (float, ),
46
self.subcategory = None
48
self.application = None
51
self.vadjustment = 0.0
53
def __setattr__(self, name, val):
56
raise AttributeError("The attr name \"%s\" is not permitted" %
59
if not isinstance(val, attrs[name]):
60
msg = "Attribute %s expects %s, got %s" % (name, attrs[name],
64
return object.__setattr__(self, name, val)
67
s = utf8('%s %s "%s" %s %s') % \
76
state = DisplayState()
77
state.channel = self.channel
78
state.category = self.category
79
state.subcategory = self.subcategory
80
state.search_term = self.search_term
81
state.application = self.application
82
state.limit = self.limit
84
state.filter = self.filter.copy()
87
state.vadjustment = self.vadjustment
93
self.subcategory = None
95
self.application = None
99
self.vadjustment = 0.0