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

« back to all changes in this revision

Viewing changes to src/View/AbstractDirectoryView.vala

merge various-fixes-part2-fix-prepare-network-location r2046

Show diffs side-by-side

added added

removed removed

Lines of Context:
584
584
        /* Signal could be from subdirectory as well as slot directory */
585
585
        protected void connect_directory_handlers (GOF.Directory.Async dir) {
586
586
            assert (dir != null);
587
 
            dir.file_loaded.connect (on_directory_file_loaded);
588
587
            dir.file_added.connect (on_directory_file_added);
589
588
            dir.file_changed.connect (on_directory_file_changed);
590
589
            dir.file_deleted.connect (on_directory_file_deleted);
591
590
            dir.icon_changed.connect (on_directory_file_icon_changed);
 
591
            dir.thumbs_loaded.connect (on_directory_thumbs_loaded);
 
592
            connect_directory_loading_handlers (dir);
 
593
        }
 
594
 
 
595
        protected void connect_directory_loading_handlers (GOF.Directory.Async dir) {
 
596
            dir.file_loaded.connect (on_directory_file_loaded);
592
597
            dir.done_loading.connect (on_directory_done_loading);
593
 
            dir.thumbs_loaded.connect (on_directory_thumbs_loaded);
 
598
        }
 
599
 
 
600
        protected void disconnect_directory_loading_handlers (GOF.Directory.Async dir) {
 
601
            dir.file_loaded.disconnect (on_directory_file_loaded);
 
602
            dir.done_loading.disconnect (on_directory_done_loading);
594
603
        }
595
604
 
596
605
        protected void disconnect_directory_handlers (GOF.Directory.Async dir) {
597
606
            /* If the directory is still loading the file_loaded signal handler
598
607
            /* will not have been disconnected */
599
608
 
600
 
            if (dir.is_loading ())
601
 
                dir.file_loaded.disconnect (on_directory_file_loaded);
 
609
            if (dir.is_loading ()) {
 
610
                disconnect_directory_loading_handlers (dir);
 
611
            }
602
612
 
603
613
            dir.file_added.disconnect (on_directory_file_added);
604
614
            dir.file_changed.disconnect (on_directory_file_changed);
614
624
                style_context.remove_class (MESSAGE_CLASS);
615
625
 
616
626
            cancel ();
 
627
            clear ();
 
628
            disconnect_directory_handlers (old_dir);
 
629
            connect_directory_handlers (new_dir);
 
630
        }
 
631
 
 
632
        public void clear () {
 
633
            /* after calling this (prior to reloading), the directory must be re-initialised so
 
634
             * we reconnect the file_loaded and done_loading signals */
617
635
            freeze_tree ();
618
 
            disconnect_directory_handlers (old_dir);
619
636
            block_model ();
620
637
            model.clear ();
621
638
            unblock_model ();
622
 
            /* As we connect the signal file_loaded signal handler, we initialise. */
623
 
            connect_directory_handlers (new_dir);
624
 
        }
625
 
 
626
 
        public void reload () {
627
 
            change_directory (slot.directory, slot.directory);
 
639
            connect_directory_loading_handlers (slot.directory);
 
640
            /* tree will be thawed after done loading */
628
641
        }
629
642
 
630
643
        protected void connect_drag_drop_signals (Gtk.Widget widget) {
812
825
 
813
826
            /* If in recent "folder" we need to refresh the view. */
814
827
            if (in_recent) {
815
 
                slot.directory.clear_directory_info ();
816
 
                slot.directory.need_reload ();
 
828
                slot.reload ();
817
829
            }
818
830
        }
819
831
 
906
918
            }
907
919
 
908
920
            var file_to_rename = GOF.File.@get (new_file);
909
 
            view.slot.reload (true); /* non-local only */
910
 
 
911
921
            view.rename_file (file_to_rename); /* will wait for file to appear in model */
912
922
        }
913
923
 
920
930
 
921
931
            view.slot.directory.unblock_monitor ();
922
932
            view.can_trash_or_delete = true;
923
 
            view.slot.reload (true); /* non-local only */
924
933
        }
925
934
 
926
935
        private void trash_or_delete_selected_files (bool delete_immediately = false) {
934
943
            unowned GLib.List<GOF.File> selection = get_selected_files_for_transfer ();
935
944
            if (selection != null) {
936
945
                can_trash_or_delete = false;
937
 
 
938
946
                trash_or_delete_files (selection, true, delete_immediately);
939
947
            }
940
948
        }
1205
1213
                        pasted_files_list.prepend (k as File);
1206
1214
                });
1207
1215
 
1208
 
                view.slot.reload (true); /* non-local only */
1209
1216
                view.select_glib_files (pasted_files_list, pasted_files_list.first ().data);
1210
1217
                return false;
1211
1218
            });
1286
1293
 
1287
1294
        private void  on_directory_done_loading (GOF.Directory.Async dir) {
1288
1295
            /* Should only be called on directory creation or reload */
1289
 
            dir.file_loaded.disconnect (on_directory_file_loaded);
1290
 
            dir.done_loading.disconnect (on_directory_done_loading);
 
1296
            disconnect_directory_loading_handlers (dir);
1291
1297
            in_trash = slot.directory.is_trash;
1292
1298
            in_recent = slot.directory.is_recent;
1293
1299
            in_network_root = slot.directory.file.is_root_network_folder ();
1563
1569
            if (drop_occurred) {
1564
1570
                drop_occurred = false;
1565
1571
                if (current_actions != Gdk.DragAction.DEFAULT) {
1566
 
                    slot.reload (true); /* non-local only */
1567
 
 
1568
1572
                    switch (info) {
1569
1573
                        case Marlin.TargetType.XDND_DIRECT_SAVE0:
1570
1574
                            success = dnd_handler.handle_xdnddirectsave  (context,
2723
2727
                (path != null && hover_path != null && path.compare (hover_path) != 0)) {
2724
2728
 
2725
2729
                /* cannot get file info while network disconnected */
2726
 
                if (slot.directory.is_local || slot.directory.check_network ()) {
2727
 
                    /* cannot get file info while network disconnected */
 
2730
                if (slot.directory.is_local || NetworkMonitor.get_default ().get_network_available ()) {
 
2731
                    /* cannot get file info while network disconnected. */
2728
2732
                    item_hovered (file);
2729
2733
                    hover_path = path;
2730
 
                } else {
2731
 
                    slot.reload (true); /* non-local only */
2732
2734
                }
2733
2735
            }
2734
2736
 
2817
2819
            }
2818
2820
 
2819
2821
            on_name_editing_canceled ();
2820
 
 
2821
 
            if (new_name != original_name)
2822
 
                slot.reload (true); /* non-local only */
2823
2822
        }
2824
2823
 
2825
2824
 
2847
2846
                                                                  view.original_name);
2848
2847
 
2849
2848
                view.select_gof_file (file);  /* Select and scroll to show renamed file */
2850
 
                view.slot.reload (true);
2851
2849
            }
2852
2850
 
2853
2851
            if (pw != null) {
2862
2860
            /* If folder is empty, draw the empty message in the middle of the view
2863
2861
             * otherwise pass on event */
2864
2862
            var style_context = get_style_context ();
2865
 
            if (slot.directory.is_empty () || slot.directory.permission_denied) {
 
2863
            if (slot.directory.is_empty ()) {
2866
2864
                Pango.Layout layout = create_pango_layout (null);
2867
2865
 
2868
2866
                if (!style_context.has_class (MESSAGE_CLASS))
2869
2867
                    style_context.add_class (MESSAGE_CLASS);
2870
2868
 
2871
 
                if (slot.directory.permission_denied)
 
2869
 
 
2870
                if (slot.directory.permission_denied) {
2872
2871
                    layout.set_markup (slot.denied_message, -1);
2873
 
                else if (slot.directory.is_trash) /* must be empty */
 
2872
                } else if (slot.directory.is_trash) {
2874
2873
                    layout.set_markup (slot.empty_trash_message, -1);
2875
 
                else if (slot.directory.location.get_uri_scheme () == "recent")
 
2874
                } else if (slot.directory.is_recent) {
2876
2875
                    layout.set_markup (slot.empty_recents_message, -1);
2877
 
                else
 
2876
                } else {
2878
2877
                    layout.set_markup (slot.empty_message, -1);
 
2878
                }
2879
2879
 
2880
2880
                Pango.Rectangle? extents = null;
2881
2881
                layout.get_extents (null, out extents);
2888
2888
                get_style_context ().render_layout (cr, x, y, layout);
2889
2889
 
2890
2890
                return true;
2891
 
            } else if (style_context.has_class (MESSAGE_CLASS))
 
2891
            } else if (style_context.has_class (MESSAGE_CLASS)) {
2892
2892
                style_context.remove_class (MESSAGE_CLASS);
 
2893
            }
2893
2894
 
2894
2895
            return false;
2895
2896
        }