~guillaume86/exaile/context-dev

« back to all changes in this revision

Viewing changes to xl/collection.py

  • Committer: guillaume86
  • Date: 2009-07-25 14:58:51 UTC
  • mfrom: (2141.1.50 exaile-0.3.0)
  • Revision ID: guillaume86-20090725145851-5mtd72f9ze9u1ma6
Added a little hack to adjust zoom level for the new webkit version (and yeah it's working with the ppa version now!)

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
        self._scan_stopped = False
75
75
        self._running_count = 0
76
76
        self._running_total_count = 0
 
77
        self._frozen = False
 
78
        self._libraries_dirty = False
77
79
        pickle_attrs += ['_serial_libraries']
78
80
        trackdb.TrackDB.__init__(self, name, location=location,
79
81
                pickle_attrs=pickle_attrs)
80
82
        COLLECTIONS.add(self)
81
83
 
 
84
    def freeze_libraries(self):
 
85
        """
 
86
            Prevents "libraries_modified" events from being sent from individual
 
87
            add and remove library calls.
 
88
 
 
89
            Call this before making bulk changes to the libraries. Call
 
90
            thaw_libraries when you are done; this sends a single event if the
 
91
            libraries were modified.
 
92
        """
 
93
        self._frozen = True
 
94
 
 
95
    def thaw_libraries(self):
 
96
        """
 
97
            Re-allow "libraries_modified" events from being sent from individual
 
98
            add and remove library calls. Also sends a "libraries_modified"
 
99
            event if the libraries have ben modified since the last call to
 
100
            freeze_libraries.
 
101
        """
 
102
        # TODO: This method should probably be synchronized.
 
103
        self._frozen = False
 
104
        if self._libraries_dirty:
 
105
            self._libraries_dirty = False
 
106
            event.log_event('libraries_modified', self, None)
 
107
 
82
108
    def add_library(self, library):
83
109
        """
84
110
            Add this library to the collection
87
113
            :type library: :class:`Library`
88
114
        """
89
115
        loc = library.get_location()
90
 
        if loc not in self.libraries.keys():
 
116
        if loc not in self.libraries:
91
117
            self.libraries[loc] = library
92
118
            library.set_collection(self)
93
119
        else:
95
121
        self.serialize_libraries()
96
122
        self._dirty = True
97
123
 
 
124
        if self._frozen:
 
125
            self._libraries_dirty = True
 
126
        else:
 
127
            event.log_event('libraries_modified', self, None)
 
128
 
98
129
    def remove_library(self, library):
99
130
        """
100
131
            Remove a library from the collection
120
151
        self.serialize_libraries()
121
152
        self._dirty = True
122
153
 
 
154
        if self._frozen:
 
155
            self._libraries_dirty = True
 
156
        else:
 
157
            event.log_event('libraries_modified', self, None)
 
158
 
123
159
    def stop_scan(self):
124
160
        """
125
161
            Stops the library scan