~sschuhmann/scratch/gtk-stack

« back to all changes in this revision

Viewing changes to plugins/filemanager/FileView.vala

  • Committer: Steffen Schuhmann
  • Date: 2014-08-04 23:29:01 UTC
  • mfrom: (1253.2.90 scratch)
  • Revision ID: schuhmannsteffen+launchpad@mailbox.org-20140804232901-7nxhyvay51wqg0m5
MergedĀ againstĀ upstreamĀ 

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
            
44
44
            settings = new Settings ();
45
45
 
46
 
            this.set_sort_func ((a, b) => {
47
 
                return File.compare ((a as Item).file, (b as Item).file);
48
 
            });
49
 
            
50
46
            restore_settings ();
51
47
        }
52
48
 
177
173
    }
178
174
 
179
175
    /**
180
 
     * Common interface for normal and expandable items.
 
176
     * Common abstract class for normal and expandable items.
181
177
     */
182
 
    internal interface Item : Granite.Widgets.SourceList.Item {
183
 
        public abstract File file { get; construct; }
184
 
        public abstract string path { get; }
 
178
    internal class Item : Granite.Widgets.SourceList.ExpandableItem, Granite.Widgets.SourceListSortable {
 
179
        public File file { get; construct; }
 
180
        public string path { get { return file.path; } }
 
181
 
 
182
        public int compare (Granite.Widgets.SourceList.Item a,
 
183
                                Granite.Widgets.SourceList.Item b) {
 
184
            if (a is FolderItem && b is FileItem) {
 
185
                return -1;
 
186
            } else if (a is FileItem && b is FolderItem) {
 
187
                return 1;
 
188
            }
 
189
            return File.compare ((a as Item).file, (b as Item).file);
 
190
        }
 
191
        
 
192
        public bool allow_dnd_sorting () {
 
193
            return false;
 
194
        }
185
195
    }
186
196
 
187
197
    /**
188
198
     * Normal item in the source list, represents a textfile.
189
199
     * TODO Remove, Rename
190
200
     */
191
 
    internal class FileItem : Granite.Widgets.SourceList.Item, Item {
 
201
    internal class FileItem : Item {
192
202
 
193
203
        //Gtk.Menu menu;
194
204
        //Gtk.MenuItem item_trash;
195
205
 
196
 
        public File file { get; construct; }
197
 
        public string path { get { return file.path; } }
198
 
 
199
206
        public FileItem (File file) requires (file.is_valid_textfile) {
200
207
            Object (file: file);
201
208
 
226
233
     * Monitored for changes inside the directory.
227
234
     * TODO remove, rename, create new file
228
235
     */
229
 
    internal class FolderItem : Granite.Widgets.SourceList.ExpandableItem, Item {
 
236
    internal class FolderItem : Item {
230
237
 
231
238
        //Gtk.Menu menu;
232
239
        //Gtk.MenuItem item_trash;
237
244
        
238
245
        public FileView view { get; construct; }
239
246
        
240
 
        public File file { get; construct; }
241
 
        public string path { get { return file.path; } }
242
 
        
243
247
        public signal void folder_open (GLib.File folder);
244
248
        
245
249
        public FolderItem (File file, FileView view) requires (file.is_valid_directory) {