~jeremywootten/pantheon-files/fix-backspace-in-columnv-view

« back to all changes in this revision

Viewing changes to libcore/BookmarkList.vala

  • Committer: jeremy at elementaryos
  • Date: 2016-04-30 11:11:40 UTC
  • mfrom: (2023.1.107 pantheon-files)
  • Revision ID: jeremy@elementaryos.org-20160430111140-ez2siepsfxwj9asi
Merge trunk to r2130

Show diffs side-by-side

added added

removed removed

Lines of Context:
130
130
        }
131
131
 
132
132
        public void insert_uris (GLib.List<string> uris, uint index) {
 
133
            if (index > list.length ()) {
 
134
                critical ("Bookmarklist: Attempt to insert uri at out of range index");
 
135
                return;
 
136
            }
133
137
            uris.@foreach ((uri) => {
134
138
                insert_item_internal (new Bookmark.from_uri (uri, null), index);
135
139
                index++;
184
188
        }
185
189
 
186
190
        public void move_item (uint index, uint destination) {
187
 
            assert (index < list.length ());
188
 
            if (destination > list.length ())
189
 
                destination = list.length ();
190
 
 
191
 
            if (index == destination)
192
 
                return;
 
191
            if (index > list.length ()) {
 
192
                critical ("Bookmarklist: Attempt to move bookmark from out of range index");
 
193
                return;
 
194
            }
 
195
 
 
196
            if (destination > list.length ()) {
 
197
                critical ("Bookmarklist: Attempt to move bookmark to out of range index");
 
198
                return;
 
199
            }
 
200
 
 
201
            if (index == destination) {
 
202
                return;
 
203
            }
193
204
 
194
205
            unowned GLib.List<Marlin.Bookmark> link = list.nth (index);
195
206
            list.remove_link (link);
196
 
 
197
 
            if (destination > index)
198
 
                destination--;
199
 
 
200
207
            list.insert (link.data, (int)destination);
201
208
            save_bookmarks_file ();
202
209
        }
206
213
        }
207
214
 
208
215
        private void insert_item_internal (Marlin.Bookmark bm, uint index) {
209
 
            if (this.contains (bm))
210
 
                return;
 
216
            if (this.contains (bm)) {
 
217
                return;
 
218
            }
 
219
            /* Do not insert bookmark for home or filesystem root (already have builtins) */
 
220
            var path = bm.gof_file.location.get_path ();
 
221
            if ((path == Environment.get_home_dir () || path == Path.DIR_SEPARATOR_S)) {
 
222
                return;
 
223
            }
211
224
 
212
225
            list.insert (bm, (int)index);
213
226
            start_monitoring_bookmark (bm);