~ricotz/plank/dbus

« back to all changes in this revision

Viewing changes to lib/Items/DockContainer.vala

  • Committer: Rico Tzschichholz
  • Date: 2015-03-16 17:05:01 UTC
  • Revision ID: ricotz@ubuntu.com-20150316170501-z5i4237jeij7vni7
item: Rename protected arraylist-fields *_items to *_elements

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
                 */
56
56
                public Gee.ArrayList<DockElement> Elements {
57
57
                        get {
58
 
                                return visible_items;
 
58
                                return visible_elements;
59
59
                        }
60
60
                }
61
61
                
62
 
                protected Gee.ArrayList<DockElement> visible_items;
63
 
                protected Gee.ArrayList<DockElement> internal_items;
 
62
                protected Gee.ArrayList<DockElement> visible_elements;
 
63
                protected Gee.ArrayList<DockElement> internal_elements;
64
64
                
65
65
                /**
66
66
                 * Creates a new container for dock elements.
72
72
                
73
73
                construct
74
74
                {
75
 
                        visible_items = new Gee.ArrayList<DockElement> ();
76
 
                        internal_items = new Gee.ArrayList<DockElement> ();
 
75
                        visible_elements = new Gee.ArrayList<DockElement> ();
 
76
                        internal_elements = new Gee.ArrayList<DockElement> ();
77
77
                        
78
78
                        connect_element (placeholder_item);
79
79
                }
82
82
                {
83
83
                        disconnect_element (placeholder_item);
84
84
                        
85
 
                        visible_items.clear ();
 
85
                        visible_elements.clear ();
86
86
                        
87
87
                        var items = new Gee.HashSet<DockElement> ();
88
 
                        items.add_all (internal_items);
 
88
                        items.add_all (internal_elements);
89
89
                        foreach (var item in items) {
90
90
                                remove_item_without_signaling (item);
91
91
                                item.Container = null;
92
92
                        }
93
 
                        internal_items.clear ();
 
93
                        internal_elements.clear ();
94
94
                }
95
95
                
96
96
                /**
112
112
                 */
113
113
                public bool add_item (DockElement item, DockElement? target = null)
114
114
                {
115
 
                        if (internal_items.contains (item)) {
 
115
                        if (internal_elements.contains (item)) {
116
116
                                critical ("Item '%s' already exists in this DockItemProvider.", item.Text);
117
117
                                return false;
118
118
                        }
146
146
                        bool result = true;
147
147
                        
148
148
                        foreach (var item in items) {
149
 
                                if (internal_items.contains (item)) {
 
149
                                if (internal_elements.contains (item)) {
150
150
                                        critical ("Item '%s' already exists in this DockItemProvider.", item.Text);
151
151
                                        result = false;
152
152
                                        continue;
177
177
                 */
178
178
                public bool remove_item (DockElement item)
179
179
                {
180
 
                        if (!internal_items.contains (item)) {
 
180
                        if (!internal_elements.contains (item)) {
181
181
                                critical ("Item '%s' does not exist in this DockItemProvider.", item.Text);
182
182
                                return false;
183
183
                        }
194
194
                        Logger.verbose ("DockItemProvider.update_visible_items ()");
195
195
                        
196
196
                        var old_items = new Gee.ArrayList<DockElement> ();
197
 
                        old_items.add_all (visible_items);
198
 
                        
199
 
                        visible_items.clear ();
200
 
                        
201
 
                        foreach (var item in internal_items)
 
197
                        old_items.add_all (visible_elements);
 
198
                        
 
199
                        visible_elements.clear ();
 
200
                        
 
201
                        foreach (var item in internal_elements)
202
202
                                if (item.IsVisible)
203
 
                                        visible_items.add (item);
 
203
                                        visible_elements.add (item);
204
204
                        
205
205
                        var added_items = new Gee.ArrayList<DockElement> ();
206
 
                        added_items.add_all (visible_items);
 
206
                        added_items.add_all (visible_elements);
207
207
                        added_items.remove_all (old_items);
208
208
                        
209
209
                        var removed_items = old_items;
210
 
                        removed_items.remove_all (visible_items);
 
210
                        removed_items.remove_all (visible_elements);
211
211
                        
212
 
                        if (visible_items.size <= 0)
213
 
                                visible_items.add (placeholder_item);
 
212
                        if (visible_elements.size <= 0)
 
213
                                visible_elements.add (placeholder_item);
214
214
                        
215
215
                        if (added_items.size > 0 || removed_items.size > 0)
216
216
                                items_changed (added_items, removed_items);
231
231
                        
232
232
                        int index_move, index_target;
233
233
                        
234
 
                        if ((index_move = internal_items.index_of (move)) < 0) {
 
234
                        if ((index_move = internal_elements.index_of (move)) < 0) {
235
235
                                critical ("Item '%s' does not exist in this DockItemProvider.", move.Text);
236
236
                                return false;
237
237
                        }
238
238
                        
239
 
                        if ((index_target = internal_items.index_of (target)) < 0) {
 
239
                        if ((index_target = internal_elements.index_of (target)) < 0) {
240
240
                                critical ("Item '%s' does not exist in this DockItemProvider.", target.Text);
241
241
                                return false;
242
242
                        }
243
243
                        
244
 
                        move_item (internal_items, index_move, index_target);
 
244
                        move_item (internal_elements, index_move, index_target);
245
245
                        
246
 
                        if ((index_move = visible_items.index_of (move)) >= 0
247
 
                                && (index_target = visible_items.index_of (target)) >= 0) {
 
246
                        if ((index_move = visible_elements.index_of (move)) >= 0
 
247
                                && (index_target = visible_elements.index_of (target)) >= 0) {
248
248
                                var moved_items = new Gee.ArrayList<unowned DockElement> ();
249
 
                                move_item (visible_items, index_move, index_target, moved_items);
 
249
                                move_item (visible_elements, index_move, index_target, moved_items);
250
250
                                item_positions_changed (moved_items);
251
251
                        } else {
252
252
                                update_visible_items ();
260
260
                 */
261
261
                public override void reset_buffers ()
262
262
                {
263
 
                        foreach (var item in internal_items)
 
263
                        foreach (var item in internal_elements)
264
264
                                item.reset_buffers ();
265
265
                }
266
266
                
267
267
                protected virtual void add_item_without_signaling (DockElement item)
268
268
                {
269
 
                        internal_items.add (item);
 
269
                        internal_elements.add (item);
270
270
                        
271
271
                        item.Container = this;
272
272
                        item.AddTime = GLib.get_monotonic_time ();
287
287
                        
288
288
                        int index;
289
289
                        
290
 
                        if ((index = internal_items.index_of (old_item)) < 0) {
 
290
                        if ((index = internal_elements.index_of (old_item)) < 0) {
291
291
                                critical ("Item '%s' does not exist in this DockItemProvider.", old_item.Text);
292
292
                                return false;
293
293
                        }
294
294
                        
295
 
                        if (internal_items.contains (new_item)) {
 
295
                        if (internal_elements.contains (new_item)) {
296
296
                                critical ("Item '%s' already exists in this DockItemProvider.", new_item.Text);
297
297
                                return false;
298
298
                        }
306
306
                        
307
307
                        disconnect_element (old_item);
308
308
                        
309
 
                        internal_items[index] = new_item;
 
309
                        internal_elements[index] = new_item;
310
310
                        old_item.Container = null;
311
311
                        new_item.Container = this;
312
312
                        
314
314
                        //FIXME new_item.Position = old_item.Position;
315
315
                        connect_element (new_item);
316
316
                        
317
 
                        if (visible_items.contains (old_item))
 
317
                        if (visible_elements.contains (old_item))
318
318
                                update_visible_items ();
319
319
                        
320
320
                        return true;
325
325
                        item.RemoveTime = GLib.get_monotonic_time ();
326
326
                        disconnect_element (item);
327
327
                        
328
 
                        internal_items.remove (item);
 
328
                        internal_elements.remove (item);
329
329
                        item.Container = null;
330
330
                }
331
331